NEW YORK — Former New York mayor Mike Bloomberg, who has moved toward joining the Democratic presidential race, apologized Sunday for his handling of stop-and-frisk, a policing tactic that has been criticized as a kind of racial profiling and that Bloomberg defended as recently as early this year.

Bloomberg expressed regrets at a predominantly black megachurch he has visited many times, telling congregants he didn’t understand the full effects on African American and Latino communities quickly enough and should have curtailed the program sooner.

“I’m sorry that we didn’t,” Bloomberg said. “But I can’t change history. However, today, I want you to know that I realize back then, I was wrong.”

The speech served as one of the clearest indicators yet that the billionaire businessman might soon join the crowded Democratic primary. Bloomberg has filed paperwork to run in Alabama and Arkansas and has mapped out a strategy that would largely bypass the four earliest nominating states. Instead, he would focus on later contests of note, including those in Southern states with large black populations.

Bloomberg’s attempt to confront one of his biggest potential liabilities reflects the ongoing shift in the Democratic Party on issues of race, criminal justice and police violence. Voters and activists are increasingly demanding their leaders take firmer stances against discrimination by law enforcement and reject tough-on-crime policies that were more widely accepted decades ago.

This dynamic poses a challenge to older white candidates, such as former vice president Joe Biden, and it could create tough choices for many voters of color in the coming months. Biden and Bloomberg have complicated records on racial issues, with accomplishments lauded in minority communities and decisions panned in those same areas.

“I got something important wrong,” said Bloomberg, who grew visibly emotional at times during his speech. “I got something important really wrong.”

Biden performs well among black voters, polls show. Bloomberg is hoping to make his own inroads in coming months.

But it’s far from clear whether his apology, delivered in a highly controlled setting, will work. He gave his speech at the Christian Cultural Center, a familiar venue he had been to 17 times before, according to an aide. Bloomberg received a subdued round of applause at the end of the speech.

“Many people will see it as mixed,” said NAACP chief executive and President Derrick Johnson, speaking about Bloomberg’s record. Stop-and-frisk was “extremely problematic,” Johnson said, but, “at the exact same time, he’s been a strong supporter of gun reform and against gun violence. And that’s a positive thing.”

The Police Benevolent Association, New York’s largest police union, dismissed the apology as “too little, too late.” Patrick J. Lynch, the group’s president, said in a statement that officers had warned “that the quota-driven emphasis on street stops was polluting the relationship between cops and our communities.”

Bloomberg’s potential candidacy and the way his record is perceived are surprise variables in a fluid Democratic race that has taken many twists and turns. Pete Buttigieg, a once-little-known mayor from South Bend, Ind., has surged to the lead in a new Iowa poll. Former Massachusetts governor Deval Patrick just threw his hat into the ring. Biden has held his lead in many national polls. And Sens. Elizabeth Warren (D-Mass.) and Bernie Sanders (I-Vt.) have posted huge fundraising numbers that have boosted their chances.

From the start of 2002 until the end of 2013, Bloomberg served as mayor of the country’s most populous city, first as a Republican and later as an independent. During much of his tenure, the New York Police Department stepped up its use of stop-and-frisk. The most dramatic increases occurred during his first five years, according to department data analyzed by the New York Civil Liberties Union.

Stop-and-frisk refers to the practice of police officers stopping, questioning and searching people they suspect may have committed crimes or are about to do so. The NYCLU analysis found that the stops disproportionately targeted young black and Latino men and that the vast majority did not result in arrests or summonses — a point Bloomberg acknowledged Sunday.

“Far too many innocent people were being stopped,” he said. “And the overwhelming majority of them were black and Latino. That may have included, I’m sorry to say, some of you here today.”

“Perhaps yourself or your children or grandchildren, or your neighbors or your relatives,” he added.

Bloomberg said repeatedly during his remarks that his focus was on saving lives. The NYCLU analysis, however, found that searches yielded weapons a small percentage of the time. A Washington Post analysis of data from the Brennan Center for Justice and the FBI found no correlation between stop-and-frisk and the reduction of violent crime in New York City.

In 2013, a federal judge ruled that the stop-and-frisk law was unconstitutional and said the city had engaged in indirect racial profiling. Bloomberg sought Sunday to underscore his efforts to reduce the number of stops before that time.

During a sometimes pointed question-and-answer session at the Naval Academy in January, Bloomberg defended his record on stop-and-frisk, saying police “certainly” did not stop people based on their race.

Bloomberg concluded his Sunday speech without making any firm commitments to running for president. “I don’t know what the future holds for me,” he said.

In the audience, Laruth Williams, 67, said Bloomberg’s apology was “surprising” and “sincere.” Lorna Lewis, 74, also said she felt he was sincere, but added, “I think he has to do a little bit more.”

Some associates and observers predict he will soon enter the race. Although his record is controversial, he is showing some signs of progress with African American leaders.

The Rev. Al Sharpton said he recently attended an Alabama state Baptist convention and found black support for Bloomberg. “Two or three ministers asked me about Bloomberg fairly positively,” he said. Little Rock Mayor Frank Scott Jr. met with Bloomberg and said he left a “great first impression.”

Still, he faces an imposing challenger in Biden, who has formed close ties with many African American leaders and has been outpacing his rivals among black voters in the polls.

Yet Biden has also faced scrutiny over his record on race, including his spearheading of a 1994 crime law that led to increased incarceration levels as well as his controversial comments about a segregationist senator and busing.

Asked if he could support a Bloomberg presidential bid, Sharpton said he was still undecided but that he would ultimately have to consider Bloomberg’s record on stop-and-frisk against the records of “candidates that supported the crime bill that was devastating,” a reference to votes by Biden and Sanders for the 1994 law.

Bloomberg’s aggressive and well-funded initiative to tighten gun laws and elect members of Congress committed to placing new regulations on firearms could help boost his appeal to African American leaders and voters.

That doesn’t mean they will soon forget stop-and-frisk.

“Like any candidate offering themselves up for public office, we’re always going to have good and bad,” Johnson said.

Scherer reported from Washington. Mark Berman contributed to this report.