By the skin of one’s teeth

Meaning: Only just; by a very narrow margin.

Example: We caught the train by the skin of our teeth.