The violation of a Bell inequality is an experimental observation that forces the abandonment of a local realistic viewpoint—namely, one in which physical properties are (probabilistically) defined before and independently of measurement, and in which no physical influence can propagate faster than the speed of light1, 2. All such experimental violations require additional assumptions depending on their specific construction, making them vulnerable to so-called loopholes. Here we use entangled photons to violate a Bell inequality while closing the fair-sampling loophole, that is, without assuming that the sample of measured photons accurately represents the entire ensemble3. To do this, we use the Eberhard form of Bell’s inequality, which is not vulnerable to the fair-sampling assumption and which allows a lower collection efficiency than other forms4. Technical improvements of the photon source5, 6 and high-efficiency transition-edge sensors7 were crucial for achieving a sufficiently high collection efficiency. Our experiment makes the photon the first physical system for which each of the main loopholes has been closed, albeit in different experiments.