In external beam radiotherapy, conventional analysis of portal images in two dimensions (2D) is limited to verification of in-plane rotations and translations of the patient. We developed and clinically tested a new method for automatic quantification of the patient setup in three dimensions (3D) using one set of computed tomography (CT) data and two transmission images. These transmission images can be either a pair of simulator images or a pair of portal images. Our procedure adjusts the position and orientation of the CT data in order to maximize the distance through bone in the CT data along lines between the focus of the irradiation unit and bony structures in the transmission images. For this purpose, bony features are either automatically detected or manually delineated in the transmission images. The performance of the method was quantified by aligning randomly displaced CT data with transmission images simulated from digitally reconstructed radiographs. In addition, the clinical performance were assessed in a limited number of images of prostate cancer and parotid gland tumor treatments. The complete procedure takes less than 2 min on a 90-MHz Pentium PC. The alignment time is 50 s for portal images and 80 s for simulator images. The accuracy is about 1 mm and 1 degrees. Application to clinical cases demonstrated that the procedure provides essential information for the correction of setup errors in case of large rotations (typically larger than 2 degrees) in the setup. The 3D procedure was found to be robust for imperfections in the delineation of bony structures in the transmission images. Visual verification of the results remains, however, necessary. It can be concluded that our strategy for automatic analysis of patient setup in 3D is accurate and robust. The procedure is relatively fast and reduces the human workload compared with existing techniques for the quantification of patient setup in 3D. In addition, the procedure improves the accuracy of treatment verification in 2D in some cases where rotational deviations in the setup occur.