Aims. Our goal is to estimate empirically the cosmic variance that affects merger fraction studies based on close pairs for the first time. Methods. We compute the merger fraction from photometric redshift close pairs with 10 h −1 kpc ≤ r p ≤ 50 h −1 kpc and Δv ≤ 500 km s −1 and measure it in the 48 sub-fields of the ALHAMBRA survey. We study the distribution of the measured merger fractions that follow a log-normal function and estimate the cosmic variance σ v as the intrinsic dispersion of the observed distribution. We develop a maximum likelihood estimator to measure a reliable σ v and avoid the dispersion due to the observational errors (including the Poisson shot noise term). Results. The cosmic variance σ v of the merger fraction depends mainly on (i) the number density of the populations under study for both the principal (n 1 ) and the companion (n 2 ) galaxy in the close pair and (ii) the probed cosmic volume V c . We do not find a significant dependence on either the search radius used to define close companions, the redshift, or the physical selection (luminosity or stellar mass) of the samples. Conclusions. We have estimated the cosmic variance that affects the measurement of the merger fraction by close pairs from observations. We provide a parametrisation of the cosmic variance with n 1 , n 2 , and V c , σ v ∝ n −0.54(n 2 /n 1 ) −0.37 . Thanks to this prescription, future merger fraction studies based on close pairs could properly account for the cosmic variance on their results.