The roommate surrendered to police after nearly three hours. (James Messerschmidt)

This terrified man had to leap in his underwear from his Chinatown building yesterday to escape his deranged roommate who attacked him at knifepoint, authorities said.

The emotionally disturbed housemate from hell allegedly slashed the 42-year-old victim on the head and then locked them together in the second-floor apartment at Madison and Rutgers streets at about 9:20 a.m., police said.

The two were fighting because the victim may have been trying to boot the 37-year-old man from the apartment, a law-enforcement source said.

“We heard glass break, so we looked up and saw a man in the window,” said Lula Phillips, a crossing guard at the corner.

“We heard him say, ‘Call the police,’ ” Phillips said.

The man shattered the window, walked across the ledge and then jumped to save himself.

He was bleeding from the head and arm.

“I saw him come out the window. There was a lot of blood, it looked like some ‘Hellraiser’ stuff,” Michael Macos, the building’s super, said in reference to the gory horror films.

The victim was rushed to Bellevue Hospital with non-life-threatening injuries at 10 a.m., officials said.

Police negotiated with the enraged roommate, who remained barricaded in the apartment with two knives for nearly three hours until he surrendered (right) at 12:10 p.m., cops said.

He was taken to Bellevue Hospital for a psychiatric evaluation, police said. Charges against the attacker were pending, police said.