An analytical method was proposed for the quantification of Cd, Pb, Mn, and Fe in ground coffee samples using energy dispersive X‐ray fluorescence (EDXRF) spectrometry. External calibration was possible using the coffee matrix itself as standards with samples previously analyzed by inductively coupled plasma optical emission spectrometry (ICP OES). The ground coffee samples were analyzed in the form of pellets, which were placed in the center of the EDXRF measuring cell for the determination of the analytes. The limits of detection were 62, 55, 86, and 76 μg/kg for Cd, Pb, Fe, and Mn, respectively. Good linearities were obtained for the calibration curves with coefficients of correlation (R) of 0.9959 for Cd, 0.9939 for Pb, 0.9929 for Fe, and 0.9909 for Mn. Precision, evaluated as the relative standard deviation (RSD) of 10 independent measurements of different cataloged samples with an approximate concentration of 400 μg/kg for each analyte, was between 6 and 14% (n = 10), demonstrating that the preparation of the samples in form of pellets was sufficient to perform analyses by EDXRF. The proposed method was applied in the determination of Cd, Pb, Fe, and Mn in ground coffee samples collected in Salvador, Bahia, Brazil. In a parallel comparative procedure, coffee samples were also analyzed by ICP OES after sample pretreatment by acid digestion. A paired Student's t test was carried out (confidence level of 95%, n = 5) and no significant difference was observed between the concentrations obtained by the proposed and comparative methods.