Birds are unique in laying eggs with pigmented shells, but for most species (e.g. most passerines, which lay white eggs speckled with reddish spots of protoporphyrin) the pigments’ function is unknown. We studied a bird population at a geologically variable site, and considered a hitherto untested hypothesis: that protoporphyrin pigments might compensate for reduced eggshell-thickness (caused partly by calcium deficiency), which is known to reduce eggshell-strength and increase eggshell-permeability. We found that pigment spots specifically demarcated thinner areas of shell, with darker spots marking yet thinner shell than paler spots. Variation in pigmentation was thus associated with variation in shell thickness both within and between clutches, so accounting for the eggshell's characteristic spot patterns. Geological variability at this site has resulted in a great range of calcium availability and, as predicted by the hypothesis, variation in calcium availability was found to affect between-clutch variation in both eggshell-mass (+) and pigmentation characteristics (−). We suggest a physiological mechanism and some important implications of these findings.