In this study, we present an algorithm for three-dimensional (3-D) dose reconstruction using portal images obtained with an electronic portal imaging device (EPID). For this purpose an algorithm for 2-D dose reconstruction, which was previously developed in our institution, was adapted. The external contour of the patient was used to correct for absorption of primary photons, but the presence of inhomogeneities was not taken into account. The accuracy of the algorithm was determined by irradiating two anthropomorphic breast phantoms with 6 MV photons. The dose values derived from portal images were compared with results from 3-D dose calculations, which, in turn, were verified with data obtained with an ionization chamber and film dosimetry. It was found that the application of contour information significantly improves the accuracy of 2-D dose reconstruction. If the total dose at the isocenter plane resulting from all treatment beams is reconstructed, the average deviation from the planned dose is 0.1%+/-1.7% (1 SD). If contour information is not available, the differences increase up to +/-20% for the individual beams. In that case, the dose can only be reconstructed with reasonable accuracy when (nearly) opposing beams are used. The average deviation of the 3-D reconstructed dose from the planned dose in the irradiated volume is 1.4%+/-5.4% (1 SD). If the irradiated volume is enclosed by planes less than 5 cm distant from the isocenter plane, then the average deviation is only 0.5%+/-3.4% (1 SD). It can be concluded that the proposed algorithm for a 3-D dose reconstruction allows a determination of the dose at the isocenter plane and the dose-volume histogram with an accuracy acceptable for an independent verification of the treatment.