Narrowly; barely; by an amount equal to the thickness of the (imaginary) skin on one’s teeth. Usually used in regard to a narrow escape from a disaster.
“I escaped the burning building by the skin of my teeth. One more second in there and I’d have been toast.”
The phrase first appears in English in the Geneva Bible, 1560, in Job 19:20. After Shakespeare, a prolific coiner of new words, the King James translation of the Bible has been the biggest source of phrases in English. Despite its old roots, the phrase doesn’t seem to have become popular until the nineteenth century.
The story of Job relates how he lost family, friends, money and health. At the end, he still kept his faith in his god and escaped, but with nothing. In this sense, he escaped with ‘the skin of his teeth,’ since teeth do not have skin.
That’s not quite the modern meaning, though. The modern meaning is ‘just barely,’ rather than ‘coming through something and having nothing afterwards.’
Based on the idea that ‘skin of one’s teeth’ means ‘just barely,’ many theories have put forward to explain it. The most plausible is that it refers to the thin porcelain exterior of the tooth, rather than the skin on the gums. This may please the literal-minded and I usually count myself among them, but in this case, I think the term means ‘nothing.’