The fact that Mr. Adams, a former police captain who is black, named Iowa and Ohio, two largely white states, could alienate some voters in a wide-open Democratic primary for mayor, where Mr. Adams is an early front-runner.

“For some of his constituents, it’s maybe a dog whistle to gentrification and the changing composition of the borough,” said Christina M. Greer, an associate professor of political science at Fordham University. “But for quite a few New Yorkers who are transplants, it’s a pretty divisive message. In a crowded mayoral field, you want to be as inclusive as possible.”

Within hours of Mr. Adams’s initial comments, Mayor Bill de Blasio pushed back against his inflammatory stance, even though Mr. Adams is a friend of the mayor’s.

“It’s not my impression he said it the right way — the fact is it’s a city for everyone,” Mr. de Blasio said in an interview on NY1. “So many New Yorkers have come here recently and are contributing a lot to the city.”

Affordability will likely be a central issue in the race to succeed Mr. de Blasio — a theme that two other candidates emphasized at Mr. Sharpton’s event on Monday, an annual rite of passage for city and state leaders. The candidates, Scott M. Stringer, the city comptroller, and Corey Johnson, the City Council speaker, pledged to focus on creating more affordable housing.

Mr. de Blasio, a Democrat in his second and final term, ran in 2013 on the theme that New York City had become a “tale of two cities” — split between the haves and the have-nots — and he vowed to battle inequality. But many New Yorkers believe he has not done enough to tackle the problem.

“That narrative is more important now than ever because the mayor has not gotten us any closer to a solution,” Professor Greer said.