BAGHDAD (AP) — Incumbent Prime Minister Nouri al-Maliki cemented his grip on power Thursday, bringing an end to nearly nine months of political deadlock after he was asked to form the next government.

He now faces the daunting task of bringing together Iraq’s Shiite, Sunni and Kurdish factions in a government that can overcome enduring tensions as the country struggles to develop its economy and prevent a resurgence of violence as the last American troops are due to leave by the end of next year.

The long-awaited request from President Jalal Talabani sets in motion a 30-day timeline during which al-Maliki must pick his Cabinet. Al-Maliki, a steely politician known more for his ability to alienate than unify, said he was aware of the challenges ahead.

"I call upon the great Iraqi people from all sects, religions and ethnicities and I call upon my brothers the politicians to work to overcome all differences," the prime minister designate said during the ceremony at the president’s palace.

The new government is expected to include all the major factions, including the Kurds, Shiite political parties aligned with Iran and a Sunni-backed bloc that believes it should have been the one leading the next government.

In many ways it is likely to be similar to the previous government. The presidency again will be held by the Kurds, the parliament speaker by the Sunnis and the prime minister’s office went to the country’s dominant sect, the Shiites. The breakdown is a reflection of the sectarian interests that still divide this country, seven years after the U.S.-led invasion.

Al-Maliki will have to find other substantial roles for all of those factions or risk having them leave his government, a destabilizing blow for a country struggling to overcome years of violence and economic sanctions.

The president’s request Thursday was largely a formality following Talabani’s re-election on Nov. 11. Talabani, a Kurd, then had 15 days in which to formally extend the offer and start the 30-day clock.

The announcement underscores what has been a stunning comeback for al-Maliki, whose State of Law coalition came in a close second in the March 7 election to the Sunni-backed bloc led by former Prime Minister Ayad Allawi. But neither bloc gained the 163-seat majority necessary to govern, leading to an intensive period of political jockeying.

Al-Maliki, 60, then mended rifts with his hard-line Shiite rivals to consolidate his power base.

A key question will be who gets to control the security ministries — interior and defense. Haider al-Abadi, a Shiite lawmaker and an al-Maliki ally, said those posts were expected to go to independent politicians not affiliated with any of the main political blocs. Such a move would avoid any risk of using the powerful ministries to settle feuds.

The Kurds, meanwhile are pushing to hold onto the foreign ministry, while Allawi’s Sunni-backed Iraqiya list has demanded the oil ministry.

Finding a role for Iraqiya is an important challenge. Sunni discontent with the Shiite domination that arose from the American overthrow of Saddam Hussein was a key reason for the bloody insurgency that just a few years ago resulted in hundreds of people dead each day.

Violence has sharply declined but attacks continue. A bomb went off in a pet store Thursday in the northern city of Tal Afar, killing at least three people and wounding 16, police and hospital officials said.

Allawi, who did not attend the meeting, was expected to be named the head of a council that would have ambiguous powers over major government decisions, according to a power-sharing deal that paved the way for al-Maliki to keep his job.

The post was pushed by the U.S. Embassy as a way to include Allawi, and address one of Iraqiya’s demands that there be a check on what they describe as al-Maliki’s increasingly autocratic and insular government. But already al-Maliki and Allawi supporters have voiced conflicting opinions over just how much power the council will have.

"The battle hasn’t ended," said Iraqiya lawmaker, Alaa Makki.

Al-Maliki will also have to weigh what role to give to followers of anti-American cleric Muqtada al-Sadr, whose support proved vital in his bid to stay in office.

The Sadrists’ anti-American stance, ties to Iran and their disturbing history as one of the major players in the country’s sectarian violence will make any Cabinet appointments a sensitive issue. But they are expected to demand a reward.

"We have about 40 parliament seats which means we have great electoral rights," said Hakim al-Zamili, a high-ranking member of the Sadrist delegation.

U.S. Ambassador to Iraq James F. Jeffrey acknowledged al-Maliki has a tough job ahead of him but was optimistic democracy would prevail.

"He’s in a strong position," Jeffrey said in an interview with The Associated Press. "But it isn’t over until it’s over, and it’s essentially 325 members of the parliament that have the final say."