do something by the skin of your teeth - definition and synonyms

phrase
  1. to succeed in doing something but almost fail

    He won, but only by the skin of his teeth.

See also main entry: skin