A quick-thinking Port Authority police sergeant was able to convince a suicidal man not to jump off a ledge at the Midtown Bus Terminal, police said.

Sgt. Rudy Fernandez was working just after 7 p.m. Wednesday when he noticed a 29-year-old man had hopped a railing, and was sitting with his legs dangling over the precipice, five stories above 42 Street.

Fernandez started talking to the man, who told him the officer that he wanted to end his life, according to a statement from the department.

The 24-year veteran of the force was able to talk the man into leaving the ledge safely about ten minutes later, authorities said.

The man was transported to Roosevelt Hospital for further attention.