An uncharacteristically emotional Mayor Bloomberg choked up during a swan-song speech Thursday that was part ode to the city and part reflection on his nearly 12 years in office.

Speaking for his eighth and final time before the Association for a Better New York, Bloomberg celebrated the values he said make the city the apple of his eye — including personal freedom, economic opportunity and artistic expression.

“The biggest risk we face . . . is the risk of failing to stay true to the values that made our city great, the values that make New York New York,” said Bloomberg, who strayed from his typical matter-of-fact delivery as his voice cracked a couple of times.

“Our administration has worked to honor and extend those values every day for nearly 12 years now,” he added. “And that, more than anything else I think, is the legacy I’m most proud of.”

Bloomberg alluded to his support for a controversial Muslim community center several blocks away from the site of the World Trade Center as one example of religious freedom here.

And his voice wavered when he read the inscription on the Statue of Liberty: “Give me your tired, your poor, your huddled masses . . .”

While he has said he’s rooting hard for the next mayor to succeed — particularly because he plans to remain a resident of the city — Bloomberg took a subtle shot at Bill de Blasio’s “Tale of Two Cities” mantra, which paints a New York divided by income inequality.

“We are one city — open to all, with equal rights for all,” Bloomberg said in a ballroom at the Brooklyn Marriott hotel, where the crowd gave him two standing ovations.

He later added, “Today, there is no city in America with a stronger social safety net than New York — and there is no city that has done more to fight poverty than we have.”