JUNGFRAU (adJUstiNg Gain detector FoR the Aramis User station) is a two-dimensional pixel detector for photon science applications at free electron lasers and synchrotron light sources. It is developed for the SwissFEL currently under construction at the Paul Scherrer Institute, Switzerland. Characteristics of this application-specific integrating circuit readout chip include single photon sensitivity and low noise over a dynamic range of over four orders of magnitude of photon input signal. These characteristics are achieved by a three-fold gain-switching preamplifier in each pixel, which automatically adjusts its gain to the amount of charge deposited on the pixel. The final JUNGFRAU chip comprises 256 × 256 pixels of 75 × 75 μm2 each. Arrays of 2 × 4 chips are bump-bonded to monolithic detector modules of about 4 × 8 cm2. Multi-module systems up to 16 Mpixels are planned for the end stations at SwissFEL. A readout rate in excess of 2 kHz is anticipated, which serves the readout requirements of SwissFEL and enables high count rate synchrotron experiments with a linear count rate capability of > 20 MHz/pixel. Promising characterization results from a 3.6 × 3.6 mm2 prototype (JUNGFRAU 0.2) with fluorescence X-ray, infrared laser and synchrotron irradiation are shown. The results include an electronic noise as low as 100 electrons root-mean-square, which enables single photon detection down to X-ray energies of about 2 keV. Noise below the Poisson fluctuation of the photon number and a linearity error of the pixel response of about 1% are demonstrated. First imaging experiments successfully show automatic gain switching. The edge spread function of the imaging system proves to be comparable in quality to single photon counting hybrid pixel detectors.