WARSAW, Poland — Poland's populist ruling party suffered a major setback in the country's mayoral races, losing not only in all large cities but also in most mid-size and smaller cities. The results Monday dashed the ruling party's ambitions for greater power nationally and showed the flaws of the party's courtship of the far right.

In mayoral races in 649 cities, towns and smaller municipalities, official results released Monday showed that Poland's ruling right-wing Law and Justice party, in power since 2015, won no big city and only a handful of the smaller cities. The largest city captured by the conservatives was Zamosc, population 65,000.

Michal Szuldrzynski, a leading editor with the Rzeczpospolita daily, said Law and Justice's results in the mid-size cities — normally bastions of the political right — were "catastrophic" for the governing party. He argued in an opinion piece the results indicated that Prime Minister Mateusz Morawiecki and the ruling party have "failed to regain a moderate center and build up support among the middle class."

Among the factors that have alienated many voters are Morawiecki's "flirting with the most radical part of the electorate," with gestures and words meant to appeal to far-right nationalists, Szuldrzynski argued.

He also listed disputes with the European Union over rule of law issues and a controversial Holocaust speech law early this year that sparked a clash with Israel, which in his view was Poland's most serious diplomatic crisis since communism fell in 1989.

Former Prime Minister Donald Tusk, now head of the European Council, said in Warsaw that he was "very surprised" by the scale of Law and Justice's defeat in smaller cities. He said the result was a warning to the ruling party and a boost to the opposition Civic Platform party, which he used to lead.

In the first round of local voting on Oct. 21, an opposition coalition led by the centrist Civic Platform won outright in the capital, Warsaw, and in other key cities, including Wroclaw, Poznan and Lodz.

In runoff races Sunday, voters handed landslide victories to opposition politicians in other prestigious cities, including Krakow, Gdansk and Kielce.

While the opposition celebrated Monday, ruling party leaders sought to keep the focus on the party's strong showing in Poland's regional assemblies two weeks ago.

Law and Justice "won the local elections of 2018," the deputy culture minister, Jaroslaw Sellin, told TVN24. "It won them like nobody has managed to do yet."

The mayoral results, however, clearly reflected the strong opposition of urban Poles to Law and Justice, which has been accused of violating democratic standards with attempts to take control of the courts and turn public media into a party propaganda tool. The Law and Justice government has also been in frequent conflict with the EU over democratic standards.

The results in Poland's mayoral races have proven a boost to Civic Platform and other opposition parties. However, many analysts warned that their relatively decent showing resulted largely from votes against the ruling party, and said that if the opposition wants a chance of governing the country it will need to increase its appeal. The opposition's defeat in some places to independent candidates seemed to reflect their vulnerability.

Overall, the local election highlighted the deep political divisions in Poland.

On one side are urban, liberal Poles who feel that the ruling populists are destroying their country's hard-won democracy.

On the other are conservatives — often older, rural and less educated voters — who appreciate the ruling party's attempts to preserve traditional Catholic values and resist what they feel are corrupting influences from Western Europe.