We present a silicon optical transmitter for polarization-encoded quantum key distribution (QKD). The chip was fabricated in a standard silicon photonic foundry process and integrated a pulse generator, intensity modulator, variable optical attenuator, and polarization modulator in a 1.3 mm $times$ 3 mm die area. The devices in the photonic circuit meet the requirements for QKD. The transmitter was used in a proof-of-concept demonstration of the BB84 QKD protocol over a 5 km long fiber link.