In this paper, a W-band 2 × 2 phased-array transmitter with digital gain compensation is proposed to minimize amplitude and angle errors of synthesized beams. The RF phase-shifting architecture is utilized for the phasedarray transmitter to reduce circuit blocks and lower system complexity. The high-resolution phase shifting is achieved by a vector-sum phase shifter, which is based on a quadrature-allpass filter (QAF) with compensation network and Gilbert-type variable gain amplifiers (VGAs) with digital-controlled current digital-to-analog converters (I-DACs). To lower the gain error introduced by the phase shifter in RF phase-shifting architecture, the variable-gain power amplifier (VGPA) is proposed. The gain of the VGPA is finely adjusted to compensate the gain variation of phase shifter in different phase states. Meanwhile, the phase variation of the VGPA under variable gain states is optimized to avoid the influence on phase errors. To verify the aforementioned mechanism, a W-band 2 × 2 phased-array transmitter is implemented and fabricated in a conventional 40nm CMOS technology. Based on the digital gain-compensation technique, the phased-array transmitter exhibits a less than 1.12dB RMS gain error and less than 1.82 • RMS phase error. In addition, the fabricated chip achieves 8.13dBm peak saturated output power and better than 9dB power gain with 135mW power consumption for each channel.