(Adds details, background)
By Matt Spetalnick
BAGHDAD, Dec 14 U.S. President George W. Bush made an unannounced farewell visit to Baghdad on Sunday, just weeks before he leaves office and bequeaths the unpopular Iraq war to President-elect Barack Obama.
Slipping out of the White House over the weekend, Bush flew secretly to the Iraqi capital to hold talks with Prime Minister Nuri al-Maliki and address a rally of U.S. troops.
"Bush has come to meet Iraqi leaders, thank the troops and celebrate the new security agreement," a White House official said.
Bush arrived first by helicopter at the presidential palace for talks with President Jalal Talabani and his two vice-presidents. He planned to meet later with Maliki.
Bush's trip -- his fourth to Iraq since the 2003 U.S.-led invasion -- follows approval of a security pact between Washington and Baghdad last month that paves the way for U.S. forces to withdraw by the end of 2011.
Bush was greeted on the heavily guarded tarmac in Baghdad by General Raymond Odierno and Ambassador Ryan Crocker.
The decision to land in broad daylight reflected confidence that Baghdad was more secure this time than during Bush's last visit to the capital in 2006 when sectarian violence was raging.
Though Iraq has slipped down the list of Americans' concerns as the recession-hit U.S. economy has taken center stage, polls show most people think the war was a mistake.
It will now be left to Obama, a Democrat and early opponent of U.S. military involvement in Iraq, to sort out an exit strategy after he takes office on Jan. 20.
About 140,000 U.S. troops will still be in Iraq nearly six years into a war that has killed more than 4,200 American military personnel and tens of thousands of Iraqis.
Bush's visit, just 11 days before Christmas, was a final chance for him to bid farewell to troops on the ground there.
Mindful of the threat still posed by militants, the White House kept a tight lid of secrecy on Bush's trip before he landed at Baghdad International Airport.
His movements were expected to be limited to the heavily fortified sites in and around the Iraqi capital.
Bush was last in Iraq in September 2007, when he flew into a U.S. air base in the restive Anbar province to underscore improved security amid a 30,000-troop buildup and growing support of Sunni tribal chiefs in the fight against al Qaeda.
Since then, there has been further progress in Baghdad and elsewhere, and Iraqi security forces are increasingly taking charge of policing streets and going after militants.
U.S. Gen. David Petraeus said last week that violence in Iraq in the past few weeks had fallen to its lowest level since mid-2003 and that security gains, while still at risk of reversal, were less fragile than before. Car bombings and suicide blasts are still common.
Bush will meet Maliki for the first time since the Iraqi government won a key concession -- Washington's agreement on a pullout timetable, something the U.S. president long opposed.
Obama pledged during the campaign to withdraw U.S. combat troops in 16 months, which will now have to reconciled with the timetable set in the new security deal.
As he prepares to step down, Bush has insisted toppling Iraqi dictator Saddam Hussein was the right thing to do.
But he said in a recent ABC interview that the "biggest regret" of his presidency was flawed intelligence that Iraq had weapons of mass destruction. He used that intelligence as a key justification for going to war. No such weapons were found.
Bush leaves the White House with public approval ratings near record lows, partly due to Iraq. The war has also damaged U.S. credibility abroad.
Bush , dressed casually and weaering a black baseball cap after his nighttime getaway from the White House, made a rare appearance in the press cabin of his airliner just before takeoff.
""Nobody knew who I was,"he joked when an aide complimented him on his 'disguise'. (Editing by Anthony Boadle)