A crazed man led authorities on a wild chase through a Manhattan federal office building yesterday that ended with him hiding in a 12th-floor ceiling.

The man showed up at the Varick Street complex at 4:49 p.m. to apply for a passport at a first-floor office but soon became irate.

That’s when the unidentified kook ran out an emergency exit and took an elevator to the 12th floor. Once there, he climbed into the ceiling by moving some tiles and tried to hide from authorities.

“I don’t know how, but somehow he got himself into the ceiling tiles,” said a baffled spokeswoman for Federal Protective Services. “Our officers approached the individual . . . and got him out and arrested him.”

The man, believed to be in his 50s, was taken to Bellevue Hospital for psychiatric evaluation.