An emotionally disturbed homeless man shouting an anti-gay slur Thursday morning came within 15 feet of New York City's first lady before cops carted him away, the mayor's spokeswoman said.

Mayor Bill de Blasio's wife, Chirlane McCray, had been outside a subway stop in Brooklyn handing out fliers in the de Blasio administration's campaign to pressure Albany to strengthen rent regulation when the man began his tirade.

The 48-year-old man had been arguing with a passerby and also spat toward a person, but "he missed," said Councilman Jumaane Williams (D-Brooklyn), who was with McCray during the incident and tried to calm the man.

Police later found a razor in the man's possession, said the mayor's spokeswoman, Karen Hinton. He did not brandish it during the encounter. He was taken to Kings County Hospital Center "for evaluation" but not arrested, Hinton and the NYPD said.

The incident occurred shortly after 9 a.m. near the Flatbush Avenue-Brooklyn College stop.

advertisement | advertise on newsday

"The first lady was not in danger," Hinton said.

McCray also has made improving access to treatment for mental illness her signature issue.

"You had an emotionally disturbed person near a subway stop in New York City," Williams said later at City Hall. "I'm not sure how much of a big shock that is."

advertisement | advertise on newsday

With Maria Alvarez