by the skin of (one's) teeth
Barely. Often used to describe something that almost didn't happen. Oh man, my car wouldn't start this morning—I just made it here by the skin of my teeth!
do something by the ˌskin of your ˈteeth
(informal) only just do something; nearly fail to do something: We thought we’d miss the plane, but in the end we caught it by the skin of our teeth.