We investigated the potential application of the genetic algorithm in the analysis of X-ray fluorescence spectra from measurement of lead in bone. Candidate solutions are first designed based on the field knowledge and the whole operation, evaluation, selection, crossover and mutation, is then repeated until a given convergence criterion is met. An average-parameters based genetic algorithm is suggested to improve the fitting precision and accuracy. Relative standard deviation (RSD%) of fitting amplitude, peak position and width is 1.3-7.1, 0.009-0.14 and 1.4-3.3, separately. The genetic algorithm was shown to make a good resolution and fitting of K lines of Pb and g elastic peaks.