BAGHDAD - U.S. President Barack Obama pushed Iraq's feuding factions to compromise on Tuesday, sounding a note of impatience as he said Iraqis should take responsibility for their country so U.S. troops could leave.

Obama, whose troop withdrawal strategy assumes Iraq staying relatively stable over the next 18 months, voiced concern that elections late this year could bring unresolved political issues to a head in a country that is only slowly emerging from years of sectarian violence in which tens of thousands died.

He flew to Baghdad on a previously unannounced trip to meet U.S. military commanders and Iraqi leaders and assess security there first-hand.

The strategy Obama announced after taking office in January aims to wind down the six-year war launched by his predecessor George W. Bush, seeking to withdraw all U.S. combat troops by the end of August 2010 and other forces by the end of 2011.

It is time for us to transition to the Iraqis. They need to take responsibility for their country ... In order to do that they need to make political accommodations, Obama told some 1,500 cheering troops at the sprawling Camp Victory U.S. base military just outside Baghdad.

Iraq experts worry that recent security gains could unravel if Iraqi factions fail to compromise on issues such as sharing oil revenues more equitably and giving Sunni Arabs, who formed the backbone of an insurgency, greater say in political life.

The Shi'ite-led government, which includes minority Kurds and Sunni Arabs, has made some reforms but often failed to reach agreement on the political issues that really matter.

Iraqi officials said both sides agreed in their meetings with Obama that recent security gains needed to be matched by progress in political accommodations.

Iraq is an important country, and it depends on political leaders for its administration toward prosperity and development in a civilized manner, the three-member presidency council led by President Jalal Talabani, a Kurd, said after they met Obama.

Obama's visit to Baghdad, which lasted just over four hours, was shrouded in the security-conscious secrecy that marked similar trips by Bush, whose legacy was defined by the war he launched in 2003 to topple Saddam Hussein.

The trip was made known only after Air Force One, flying from Istanbul at the end of Obama's first major international tour, had touched down at Baghdad International Airport.

Obama met the top U.S. commander in Iraq, General Raymond Odierno, and also held talks with Iraqi Prime Minister Nuri al-Maliki, Talabani and the two vice presidents.

His arrival came a day after a string of seemingly coordinated bombings across the Iraqi capital killed 37 people. On Tuesday, a car bomb killed nine people in a Shi'ite district in northwest Baghdad, police said.

His position on the war was a defining distinction between Obama and Bush, said Iraq government spokesman Ali al-Dabbagh.

The Iraq war is not Obama's war, and he wants to bring about a withdrawal. President Bush would often talk about a long-term presence of American troops in Iraq, whereas Obama wants a withdrawal as quickly as possible, that's the difference, and that is positive for Iraq, he said.

'CRITICAL PERIOD'

Under Obama's Iraq strategy, the roughly 140,000 U.S. troops now there will be drawn down to between 35,000 and 50,000 by the end of August 2010. Those staying until 2011 will concentrate on training Iraqi forces.

This is going to be a critical period, these next 18 months, Obama told U.S. troops at Camp Victory. You will be critical in terms of us being able to make sure Iraq is stable, that it is not a safe haven for terrorists, and we can start bringing our folks home.

Odierno told Obama that even with the recent spike in bombings, violence was at its lowest level since 2003, White House spokesman Robert Gibbs said.

But, underscoring the fragile security, U.S. officials ruled out any idea of Obama traveling by motorcade into Baghdad after bad weather forced the cancellation of a planned helicopter trip into the city to meet Iraqi leaders. Instead, Maliki and Talabani went to Camp Victory for talks with Obama.

The sectarian warfare and insurgency unleashed by the 2003 U.S.-led invasion have receded sharply over the past year, but Iraqi security forces still face huge challenges as they take on policing and military operations from the United States.

Maliki, speaking after his talks with Obama, urged foreign firms to return and invest in Iraq, saying the country was now more stable.

NATIONAL ELECTION

Iraq held its most peaceful elections since the invasion when a provincial ballot in January passed without a single major militant attack. But U.S. and Iraqi officials say tensions between rival factions are likely to rise ahead of a national election later in the year.

We've made significant political progress. You've seen a greater willingness on the part of all the factions in Iraq to resolve their issues politically and through non-violent means. But with the national elections coming up many of the unresolved issues may be brought to a head, Obama warned.

The fate of the city of Kirkuk, which sits on rich oil reserves and is claimed by Kurds as their ancestral capital, amid growing tensions between Kurds in their semi-autonomous region in the north and Arabs in Baghdad could ignite Iraq's next big ethno-sectarian conflict, analysts warn.