Aims. In this paper the calibration and in-orbit performance of the Heterodyne Instrument for the Far-Infrared (HIFI) is described. Methods. The calibration of HIFI is based on a combination of ground and in-flight tests. Dedicated ground tests to determine those instrument parameters that can only be measured accurately using controlled laboratory stimuli were carried out in the instrument level test (ILT) campaign. Special in-flight tests during the commissioning phase (CoP) and performance verification (PV) allowed the determination of the remaining instrument parameters. The various instrument observing modes, as specified in astronomical observation templates (AOTs), were validated in parallel during PV by observing selected celestial sources. Results. The initial calibration and in-orbit performance of HIFI has been established. A first estimate of the calibration budget is given. The overall in-flight instrument performance agrees with the original specification. Issues remain at only a few frequencies.