In the months before its approval in July 2016, the beverage industry, allied with grocery store owners and the Teamsters union, poured $10.6 million into the fight against the measure; supporters spent $2 million, much of it from Michael Bloomberg, the former New York mayor who has been a generous backer of soda tax initiatives across the country.

In a cash-strapped city where a quarter of all residents live in poverty, Mr. Kenney sold the tax as a revenue generator, not a nanny-state gambit to change unhealthy habits. The City Council approved the measure, 13 to 4.

Opponents immediately took their case to the courts, but last July the Supreme Court of Pennsylvania rejected their argument that the tax is illegal. The decision freed up millions of dollars in soda tax revenue that had been held in escrow and directed it toward creating 4,000 prekindergarten slots, 12 new community schools and an ambitious program to rebuild the city’s crumbling libraries and recreation centers. Next year, the city plans to add another 1,000 pre-K seats.

“It’s been an absolute success,” the mayor said on Friday after visiting a museum that was hosting dozens of children from the city’s expanded pre-K program. He said he was not especially worried about the future of the tax, and he had harsh words for the beverage industry, which last month spent more than $600,000 in its campaign to turn public opinion against the measure.

“This is all about rich white men who want to become even wealthier and who want to deny many kids of color an opportunity for an education,” he said.

Industry executives say the tax is a failure and that it goes against the will of the people. “Beverage taxes hurt working families, small local business and their employees,” said William Dermody, a spokesman from the American Beverage Association, which news reports indicate has spent more than $1 million on the city elections from April 2 through May 6. “And polls show a majority of Philadelphians want it repealed.”