The near-infrared calibration unit (NI-CU) on board Euclid’s Near-Infrared Spectrometer and Photometer (NISP) is the first astronomical calibration lamp based on light-emitting diodes (LEDs) to be operated in space. Euclid is a mission in ESA’s Cosmic Vision 2015–2025 framework to explore the dark universe and provide a next-level characterisation of the nature of gravitation, dark matter, and dark energy. Calibrating photometric and spectrometric measurements of galaxies to better than 1.5% accuracy in a survey homogeneously mapping ~14 000 deg2 of extragalactic sky requires a very detailed characterisation of near-infrared (NIR) detector properties as well as constant monitoring of them in flight. To cover two of the main contributions – relative pixel-to-pixel sensitivity and non-linearity characteristics – and to support other calibration activities, NI-CU was designed to provide spatially approximately homogeneous (<12% variations) and temporally stable illumination (0.1–0.2% over 1200 s) over the NISP detector plane with minimal power consumption and energy dissipation. NI-CU covers the spectral range ~[900,I900] nm – at cryo-operating temperature – at five fixed independent wavelengths to capture wavelength-dependent behaviour of the detectors, with fluence over a dynamic range of ≳100 from ~15 ph s−1 pixel−1 to >1500 ph s−1 pixel−1. For this functionality, NI-CU is based on LEDs. We describe the rationale behind the decision and design process, the challenges in sourcing the right LEDs, and the qualification process and lessons learned. We also provide a description of the completed NI-CU, its capabilities, and performance as well as its limits. NI-CU has been integrated into NISP and the Euclid satellite, and since Euclid’s launch in July 2023, it has started supporting survey operations.