An analytical model of the electrostatic force between the tip of a noncontact atomic force microscope (nc-AFM) and the (001) surface of an ionic crystal is reported. The model is able to account for the atomic contrast of the local contact potential difference (CPD) observed, while nc-AFM-based Kelvin probe force microscopy (KPFM) experiments. With the goal in mind to put in evidence this short-range electrostatic force, the Madelung potential arising at the surface of the ionic crystal is primarily derived. The expression of the force, which is deduced, can be split into two major contributions: the first stands for the coupling between the microscopic structure of the tip apex and the capacitor formed between the tip, the ionic crystal, and the counterelectrode and the second term depicts the influence of the Madelung surface potential on the mesoscopic part of the tip, independent of its microscopic structure. The former has the lateral periodicity of the Madelung surface potential, whereas the latter only acts as a static component, which shifts the total force. These short-range electrostatic forces are in the range of 10 pN. Beyond the dielectric properties of the crystal, a major effect, which is responsible for the atomic contrast of the KPFM signal, is the ionic polarization of the sample due to the influence of the tip/counterelectrode capacitor. When explicitly considering the crystal polarization, an analytical expression of the bias voltage to be applied on the tip to compensate for the local CPD, i.e., to cancel the short-range electrostatic force, is derived. The compensated CPD has the lateral periodicity of the Madelung surface potential. However, the strong dependence on the tip geometry, the applied modulation voltage, and the tip-sample distance, which can even lead to an overestimation of the real surface potential, makes quantitative KPFM measurements of the local CPD extremely difficult.