BAGHDAD - The UN secretary-general said Friday that provincial elections were an important step toward full democracy but told Iraqis they still have work to do before they can "enjoy genuine freedom and security and prosperity."

Ban Ki-moon made his second visit to Iraq as UN chief a day after official preliminary results showed Prime Minister Nouri al-Maliki's allies swept to victory in the vote for powerful local councils, an endorsement of his crackdown on extremism and violence.

"You have come such a long way, but still you have to go a far way to say that you will fully be able to enjoy genuine freedom and security and prosperity," he said during a meeting in Baghdad with President Jalal Talabani.

"I'm very much encouraged by what you have achieved," Ban said.

Al-Maliki said later that the relatively violence-free elections in Iraq sent a message.

"We can guarantee that sectarian and ethnic discrimination will not be back," he said during a joint news conference with Ban.

Ban's appearance -- which came nearly two years after his last visit to Baghdad in which he was forced to duck behind a podium when a rocket struck nearby -- signaled a new UN commitment to rebuilding efforts in Iraq.

The UN has been playing an increasingly active role in international efforts to bolster Iraq's government.

Those efforts suffered a severe setback after the Aug. 19, 2003, suicide truck bombing of the UN Baghdad headquarters. The blast killed 22 people, including the head of the UN mission, Sergio Vieira de Mello.

That attack prompted UN staff to flee the country. Over the years, however, they have returned, working closely with U.S. and Iraqi authorities.

UN representatives helped Iraqis prepare for the Jan. 31 balloting, in which voters chose provincial officials in 14 of Iraq's 18 provinces -- the first nationwide balloting since December 2005.

Initial returns were released Thursday, but special ballots cast separately by Iraqi security forces, detainees and hospital patients still need to be tallied before the results can be certified.

Al-Maliki's impressive showing in Baghdad and eight other provinces places the prime minister in a strong position before parliamentary elections late this year and could bolster U.S. confidence that it can begin withdrawing more of its 140,000 troops.

But his alliance did not gain an outright majority in any of the races, meaning it will be forced to establish alliances with other parties.

"Certainly coalitions will be formed," al-Maliki said, adding that negotiations between political parties were already under way.

Violence is down sharply since last year after a U.S.-Iraqi offensive broke the power of Shiite militias and after many Sunni gunmen abandoned the insurgency. U.S. military death tolls have fallen to a fraction of levels seen at the height of the war.

The relatively peaceful elections won praise from Ban, President Barack Obama and others, though tensions have been running high in the former insurgent-stronghold of Anbar where a leading sheik, Ahmed Abu Risha, has accused his Sunni rivals of rigging the election.

A Shiite cleric loyal to anti-U.S. cleric Muqtada al-Sadr also told worshippers Friday that "fraud took place during the elections," railing against those who spent millions of dollars on their campaigns.

"Let the people in Sadr City hear about this huge amount of money spent on publicity while they live without water or electricity," Sheik Muhannad al-Moussawi said during a sermon in Baghdad's main Shiite district.

Worshippers burned American and Israeli flags in the streets after the prayer service.

Other Shiite and Sunni preachers called for unity and urged the new provincial councils to work to provide much-needed basic services.

"This country has suffered so much from wrong policies and from those who have made religion a cover for their acts," Sheik Ahmed Hassan al-Taha said during prayer services at Baghdad's main Sunni mosque.

Ahmed al-Safi, an aide to the country's pre-eminent Shiite cleric, Grand Ayatollah Ali al-Sistani, warned those who won their elections not to make people regret voting for them.

"If we are to serve the citizens, these relations must be good," he said.

Meanwhile, Iraq's state minister of women's affairs, Nawal al-Samarraie, said Friday that she submitted her resignation this week over what she calls a lack of support for the widows and other women facing great hardship in the wartorn country. She said she waiting for a response from the prime minister's office.

Tens of thousands of women have been left widows by Iraq's violence. They have virtually no safety net and few job opportunities and usually depend on extended families.