By The Skin Of One's Teeth

Just barely; very narrowly.

Examples:

  • Doug passed the exam by the skin of his teeth.

Origin: c. 1600; from the Bible (Job 19:20)