A Maryland boy survived a freak accident when a 6-inch screw lodged in his skull while he was building a treehouse — landing on his head only “a millimeter” away from killing him, reports said.

Darius Foreman, 13, was at his aunt’s house in Parsonsburg working on his treehouse when he fell from a branch and his head landed on a board with a metal construction screw pointing outward, impaling his skull.

“I thought something was stuck in my hair,” Darius told the Daily Times of Salisbury on Friday.

Darius’ mother found her son walking around with the screw lodged in his skull while the wooden board was still attached. She called 911 and police officers shaved down the board to fit Darius and the wooden plank into the transport helicopter to the hospital.

“The problem was that [it] was still a big board that was impaled into his brain, and he couldn’t fit in the Medevac helicopter, so they had to wait and get another transport helicopter that was bigger,” Dr. Alan Cohen, the chief of pediatric neurosurgery at Johns Hopkins Hospital in Baltimore, told WJLA.

“I think a millimeter made a difference in this kid whether he was going to live or die,” Cohen added.

The doctor added that a delicate procedure was needed to remove the screw. X-rays showed the screw going through the sagittal sinus, a vein that keeps blood flowing between the brain and the heart. A slight move could cause “torrential hemorrhaging.”

“We carefully drilled the bone away down to the dura, the linings of the brain, so that we could manipulate the screw,” Cohen said.

The screw was removed and Darius is recovering from the procedure. He was released from the hospital on Thursday to celebrate his 13th birthday.

“You wouldn’t know that this happened to him. You wouldn’t know that he was a millimeter from death’s door,” Cohen said. “It’s a story with a happy ending.”