The next generation of radar (radio detection and ranging) systems needs to be based on software-defined radio to adapt to variable environments, with higher carrier frequencies for smaller antennas and broadened bandwidth for increased resolution1,2,3,4. Today’s digital microwave components (synthesizers and analogue-to-digital converters) suffer from limited bandwidth with high noise at increasing frequencies5,6,7, so that fully digital radar systems can work up to only a few gigahertz, and noisy analogue up- and downconversions are necessary for higher frequencies. In contrast, photonics provide high precision and ultrawide bandwidth8,9, allowing both the flexible generation of extremely stable radio-frequency signals with arbitrary waveforms up to millimetre waves10,11,12,13,14,15,16,17,18,19,20,21,22, and the detection of such signals and their precise direct digitization without downconversion23,24,25,26. Until now, the photonics-based generation and detection of radio-frequency signals have been studied separately and have not been tested in a radar system. Here we present the development and the field trial results of a fully photonics-based coherent radar demonstrator carried out within the project PHODIR27. The proposed architecture exploits a single pulsed laser for generating tunable radar signals and receiving their echoes, avoiding radio-frequency up- and downconversion and guaranteeing both the software-defined approach and high resolution. Its performance exceeds state-of-the-art electronics at carrier frequencies above two gigahertz, and the detection of non-cooperating aeroplanes confirms the effectiveness and expected precision of the system.