The CARMENES instrument, installed at the 3.5-m telescope of the Calar Alto observatory in Almeria, Spain, was conceived to deliver high-accuracy radial velocity (RV) measurements with long-term stability to search for temperate rocky planets around a sample of nearby cool stars. Moreover, the broad wavelength coverage was designed to provide a range of stellar activity indicators to assess the nature of potential RV signals and also valuable spectral information to characterise the stellar targets. Here, we describe the CARMENES Guaranteed Time Observations (GTO), which ran from 2016 to 2020 and collected 19633 spectra for a sample of 362 targets. We present the CARMENES Data Release 1 (DR1), which makes public all observations obtained during the GTO of the CARMENES survey. The CARMENES survey target selection was aimed at minimising biases and about 70% of all known M dwarfs within 10 pc accessible from Calar Alto were included. The data are pipeline-processed and high-level data products, including 18642 precise RVs for 345 targets, are derived. Time series data of spectroscopic activity indicators are also obtained. We discuss the characteristics of CARMENES data and the statistical properties of the stellar sample and the spectroscopic measurements. We show examples of the use of CARMENES data and provide a contextual view of the exoplanet population revealed by the survey, including 33 new planets, 17 reanalysed planets, and 26 confirmed planets from transiting candidate follow-up. A subsample of 238 targets is used to derive updated planet occurrence rates, yielding an overall average of 1.44+/-0.20 planets with 1M_{Earth}_<M_pl_sini<1000M_{Earth}_ and 1d<P_orb_<1000d per star, and indicating that nearly every M dwarf hosts at least one planet. All the DR1 raw data, pipeline-processed data, and high-level data products are publicly available online. CARMENES data have proven very useful to identify and measure planetary companions. They are also suitable for a variety of additional applications such as the determination of stellar fundamental and atmospheric properties, the characterisation of stellar activity, and the study of exoplanet atmospheres.