per un pelo

Etymology
lit. 'by a hair'.

Prepositional phrase

 * 1)  by a hair's breadth, by the skin of one's teeth