BAGHDAD - Iraq's president on Thursday asked incumbent Prime Minister Nouri al-Maliki to form a new government, part of a deal to end an eight-month deadlock over who would lead the country through the next four years, including the departure of the final American troops.

The long-awaited request from President Jalal Talabani sets in motion a 30-day timeline to accomplish the daunting task of finding a team that includes all of Iraq's rival factions.

"I know and you know well that the responsibility I am undertaking is not an easy task especially in the current circumstances that our country is passing through," al-Maliki said after accepting Talabani's request.

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.

Many of the politicians were in the room with al-Maliki and Talabani when the announcement was made in a show of unity that belies the country's often divisive politics.

Al-Maliki, a contentious figure in Iraqi politics who rose from obscurity to lead the government in 2006, called upon Iraqis and fellow politicians -- many who view him with distrust and animosity -- to support him in the task ahead.

"I call upon the great Iraqi people in all its sects, religions and ethnicities and I call upon my brothers the politicians to work to overcome all differences and to put these differences behind us," said the prime minister designate.

Al-Maliki will have to find substantial roles for all of those factions or risk having them leave his government, a possibly destabilizing blow for Iraq's still fragile democracy that is struggling to overcome years of violence and economic sanctions.

The president's request Thursday was largely a formality, coming after Talabani was elected on Nov. 11 and at the time publicly asked al-Maliki to form the next government. Talabani then had 15 days in which to formally extend the offer, giving al-Maliki some extra time to work out the details.

The announcement underscores what has been a stunning comeback for al-Maliki, whose State of Law coalition came in 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, which translated into an intensive period of political jockeying.

As the political discussions dragged on, so did violence, raising concerns that insurgents were trying to exploit the political vacuum to bring about more sectarian violence.

Allawi and his Iraqiya coalition were never able to gather enough support from Iraq's political parties, which are still defined largely by their sectarian allegiances.

Although Allawi himself is a Shiite, his largely Sunni coalition was viewed with suspicion by many in Iraq's political scene who still harbor deep resentment over the Sunni-dominant government that ruled Iraq under Saddam Hussein and worry about Sunnis returning to power.

That left al-Maliki, who in the end managed to pull together support from fellow Shiite political parties and the Kurds that propelled him toward a second term.

One of the most closely-watched developments will be what posts al-Maliki gives to Iraqiya. If the Sunni population believes it is blocked out of key posts and effectively kept from a meaningful role in government, it could risk a return to the sectarian violence that once ripped Iraq apart.

Al-Maliki will also have to weigh what role to give to followers of anti-American cleric Muqtada al-Sadr. The Shiite cleric's support for al-Maliki back in September was a result of pressure from neighboring Iran and is considered a key turning point in sending al-Maliki back to the prime minister's office.

But the Sadrists' anti-American stance, ties to Iran and their disturbing history as one of the major players in the country's sectarian violence, poses challenges about what cabinet posts to give them.

Al-Maliki asked the political blocs vying for top positions such as minister of oil and foreign affairs in the next government to put forward well-qualified candidates able to take on the tough challenges facing Iraq.

But ministry posts have in the past been a way to stack the government with supporters of various factions and in such an unwieldy government including all the rival groups, bureaucratic gridlock and indecision seems inevitable.