Treatment position setup errors often introduce temporal variations in the position of target relative to the planned external radiation beams. The errors can be introduced by the movement of a target relative to external setup marks or to other relevant landmarks that are used to position a patient for radiotherapy. Those variations can cause dose deviations from the planned doses and result in suboptimal treatments where part of the target is not fully irradiated or a critical structure receives more than desired radiation doses. Clinically available technology for image-guided radiotherapy can detect variations of target position. In this study, a method has been developed to correct for target position variations and restore the original beam geometries relative to the target. The technique involves three matrix transformations: (1) transformation of beams from the machine coordinate system to the patient coordinate system as in the patient geometry in the approved dosimetric plan; (2) transformation of beams from the patient coordinate system in the approved plan to the patient coordinate system that is identified at the time of treatment; (3) transformation of beams from the patient coordinate system at the time of treatment in the treatment patient geometry back to the machine coordinate system. The transformation matrix used for the second transformation is determined through the use of image-guided radiotherapy technology and image registration. By using these matrix transformations, the isocenter shift, the gantry, couch and collimator angles of the beams for the treatment, adjusted for the target shift, can be derived. With the new beam parameters, the beams will possess the same positions and orientations relative to the target as in the plan for a rigid body. This method was applied to a head phantom study, and it was found that the target shift was fully corrected in treatment and excellent agreement was found in target dose coverage between the plan and the treatment.