Just barely, very narrowly, as in Doug passed the exam by the skin of his teeth. A related term appears in the Bible (Job 19:20), where Job says, “I am escaped with the skin of my teeth,” presumably meaning he got away with nothing at all.
Both these phrases can mean at the specified time (e.g. The train arrived on time -- punctually). But in time often means early enough.