U.S. President Barack Obama greets military personnel at Camp Victory in Baghdad, Iraq, on Tuesday. ((Charles Dharapak/Associated Press))

U.S. President Barack Obama praised cheering soldiers in Baghdad on a surprise, four-hour visit Tuesday, and said he would stand by his promise to withdraw all combat troops by 2011.

"It is time for us to transition to the Iraqis. They need to take responsibility for their country," as about 600 troops cheered at Camp Victory, a U.S. military base.

"You have given Iraq the opportunity to stand on its own as a democratic country. That is an extraordinary achievement."

A deadly car bomb exploded just hours before his arrival, but the mood was festive as Obama addressed troops.

"We love you," someone yelled out.

 "I love you back," Obama responded.

Obama met with top U.S. commanders as well as senior Iraqi Leaders, including Prime Minister Nouri al-Maliki.

He "strongly encouraged" Iraqis to take political steps to unite political factions, including integrating minority Sunnis into the government and security forces.

Obama said he stressed to al-Maliki that the U.S. has no claim on Iraqi territory or resources.

"I communicated to the prime minister that we are strongly committed to an Iraq that is sovereign, stable and self-reliant," he said.

Obama spoke favourably of political progress being made in Iraq but also expressed concern to reporters that recent gains could deteriorate with the upcoming national elections, due to take place in December.

"It's important for us to use all of our influence to encourage the parties to resolve these issues in ways that are equitable. I think that my presence here can help do that," he said.

In his address to reporters, Al-Maliki said, "We assured the president that all the progress that has been made in the security area will continue," 

Obama landed in Baghdad in the evening after a two-day visit to Turkey that capped a long overseas trip, which included G20 and NATO summits in Europe.

He also met the top U.S. military commander in Iraq, Gen. Ray Odierno.

There are currently about 143,000 U.S. troops serving in Iraq.

In February, Obama pledged to withdraw 100,000 combat troops by Aug. 31, 2010, while 35,000 to 50,000 support troops will stay in the country until Dec. 31, 2011.

More than 4,000 U.S. soldiers, as well as thousands of Iraqis have died since the began in 2003.

Tuesday's trip was Obama's third to Iraq, and his first since taking office. He met with U.S. commanders and troops last summer while seeking the presidency.

With files from the Associated Press