In order to reduce the treatment margin of the moving target due to breathing, we developed a gated irradiation system for heavy-ion radiotherapy. The motion of a patient due to respiration is detected by the motion of the body surface around the chest wall. A respiratory sensor was developed using an infrared light spot and a position-sensitive detector. A timing signal to request a beam is generated in response to the respiration waveform, and a carbon beam is extracted from the synchrotron using a RF-knockout method. CT images for treatment planning are taken in synchronization with the respiratory motion. For patient positioning, digitized fluoroscopic images superimposed with the respiration waveform were used. The relation between the respiratory sensor signal and the organ motion was examined using digitized video images from fluoroscopy. The performance of our gated system was demonstrated by using the moving phantom, and dose profiles were measured in the direction of phantom motion. The timing of gate-on is set at the end of the expiratory phase, because the motion of the diaphragm is slower and more reproducible than during the inspiratory phase. The signal of the respiratory sensor shows a phase difference of 120 milliseconds between lower and upper locations on the chest wall. The motion of diaphragm is delayed by 200 milliseconds from the respiration waveform at the lower location. The beam extraction system worked according to the beam on/off logic for gating, and the gated CT scanner performed well. The lateral penumbra size of the dose profile along the moving axis was distinguishably decreased by the gated irradiation. The ratio of the nongated to gated lateral fall-off was 4.3, 3.5, and 2. 0 under the stroke of 40.0, 29.0, and 13.0 mm respectively. We developed a total treatment system of gated irradiation for heavy-ion radiotherapy. We found that with this system the target margin along the body axis could be decreased to 5-10 mm although the target moved twice or three times. Over 150 patients with lung or liver cancer had already been treated by this gated irradiation system by the end of July 1999.