Context. The ∼1700 year old PSR B0540−69 in the Large Magellanic Clouds (LMC) is considered the twin of the Crab pulsar because of its similar spin parameters, magnetic field, and energetics. PSR B0540−69 (V ∼ 22.5) is also one of the very few pulsars for which both optical pulsations and polarised emission have been measured. Its optical spectrum is fit by a power-law, ascribed to synchrotron radiation, like for the young Crab and Vela pulsars. At variance with them, however, a double break is required to join the X-ray and optical power-law spectra, with the first one possibly occurring in the near ultraviolet (nUV). Aims. Near-infrared (nIR) observations, never performed for PSR B0540−69, are crucial to determine whether the optical power-law spectrum extends to longer wavelengths or a new break occurs, like it happens for both the Crab and Vela pulsars in the mid-infrared (mIR), hinting at an even more complex particle energy and density distribution in the pulsar magnetosphere. Methods. We observed PSR B0540−69 in the J, H, and K S bands with the Very Large Telescope (VLT) to detect it, for the first time, in the nIR and characterise its optical-to-nIR spectrum. To disentangle the pulsar emission from that of its pulsar wind nebula (PWN), we obtained high-spatial resolution adaptive optics images with the NAOS-CONICA instrument (NACO). Results. We could clearly identify PSR B0540−69 in our J, H, and K S -band images and measure its flux (J = 20.14, H = 19.33, K S = 18.55, with an overall error of ±0.1 mag in each band). The joint fit to the available optical and nIR photometry with a powerlaw spectrum F ν ∝ ν −α gives a spectral index α = 0.70 ± 0.04, slightly more precise than measured in the optical only. This clearly implies that there is no spectral break between the optical and the nIR. We also detected, for the first time, the PSR B0540−69 PWN in the nIR. The comparison between our NACO images and Hubble Space Telescope (HST) optical ones does not reveal any apparent difference in the PWN morphology as a function of wavelength. The PWN optical-to-nIR spectrum is also fit by a single power-law, with spectral index α = 0.56 ± 0.03, slightly flatter than the pulsar's. Conclusions. Using NACO at the VLT, we obtained the first detection of PSR B0540−69 and its PWN in the nIR. Due to the small angular scale of the PWN (∼4 ) only the spatial resolution of the James Webb Space Telescope (JWST) will make it possible to extend the study of the pulsar and PWN spectrum towards the mid-IR.