Context. The distance to the Galactic centre (GC) is important for determining the distance scale in the Universe. The value derived by Eisenhauer et al. (2005) of 7.62 ± 0.32 kpc based on the orbit of one star around the central black hole is shorter than most other distance estimates based on a variety of different methods. Aims. To establish an independent distance to the GC with high accuracy, Population-ii Cepheids were used that have been discovered in the ogle-ii and ogle-iii surveys.Methods. Thirty-nine Population-ii Cepheids were monitored with the SOFI infrared camera on 4 nights spanning 14 days, typically obtaining between 5 and 11 epochs of data. Light curves were fitted using the known periods from the OGLE data to determine the mean K-band magnitude with an accuracy of 0.01−0.02 mag. It so happens that 37 RR Lyrae stars are in the field-of-view of the observations, and mean K-band magnitudes are derived for this sample as well. Results. After correction for reddening, the period-luminosity relation of Population-ii Cepheids in the K-band is determined, and the derived slope of −2.24 ± 0.14 is consistent with the value derived by Matsunaga et al. (2006, MNRAS, 370, 1979. Fixing the slope to their more accurate value results in a zero point and implies a distance modulus to the GC of 14.51 ± 0.12, with an additional systematic uncertainty of 0.07 mag. Similarly, from the RR Lyrae K-band period-luminosity relation, we derive a value of 14.48 ± 0.17(random) ± 0.07 (syst.). The two independent determinations are averaged to find 14.50 ± 0.10(random) ± 0.07(syst.), or 7.94 ± 0.37 ± 0.26 kpc. The absolute magnitude scale of the adopted period-luminosity relations is tied to an LMC distance modulus of 18.50 ± 0.07.