Escape by the skin of one’s teeth

Meaning: To escape or succeed by a very narrow margin.

Example: We escaped by the skin of our teeth when the building was evacuated.