X-ray fluorescence computed tomography (XFCT) allows for the reconstruction of the distribution of elements within a sample from measurements of fluorescence x rays produced by irradiation of the sample with monochromatic synchrotron radiation. XFCT is not a transmission tomography modality, but rather a stimulated emission tomography modality; thus correction for attenuation of the incident and fluorescence photons is essential if accurate images are to be obtained. This is challenging because the attenuation map is, in general, known only at the stimulating beam energy and not at the various fluorescence energies of interest. We make use of empirically fitted analytic expressions for x-ray attenuation coefficients to express the unknown attenuation maps as linear combinations of known quantities and the unknown elemental concentrations of interest. We then develop an iterative image reconstruction algorithm based on penalized-likelihood methods that have been developed for medical emission tomography. Studies with numerical phantoms indicate that the approach is able to produce qualitatively and quantitatively accurate reconstructed images even in the face of severe attenuation. We also apply the method to real synchrotron-acquired data and demonstrate a marked improvement in image quality relative to filtered backprojection reconstruction.