by a hair
Also, by a hairbreadth or whisker. Very narrowly. For example, His serve was out by a hair, or We made our flight by a hairbreadth, or Dad missed hitting the pole by a whisker. The first two hyperboles for the very narrowest margin date from the 1300s and 1400s respectively; whisker meaning "a small amount" was first recorded in 1913. Also see by the skin of one's teeth; hang by a hair.