BAGHDAD - Iraqi soldiers hoisted the nation's flag over the Basra palace compound Monday after British troops withdrew from their last garrison in the city, leaving the country's second biggest city largely in the hands in the hands of Iranian-backed Shiite militias.

At al-Asad Air Base west of Baghdad, meanwhile, President Bush made a surprise visit to Iraq, hoping to bolster his case that the buildup of U.S. troops is helping stabilizing the country.

And the U.S. command said a soldier was killed and three others injured when a roadside bomb blew up next to their patrol on Sunday outside of Baghdad. No further details were released.

British vehicles rumbled out of the gates of the sprawling Basra Palace compound after dark Sunday and headed for the Basra's international airport, about 12 miles away, where the last of Britain's 5,500 soldiers are based.

British Prime Minister Gordon Brown said the move was planned for months and that British troops would be available to help Iraqi forces "in certain circumstances.

"This is essentially a move from where we were in a combat role in four provinces, and now we are moving over time to being in an overwatch role," Brown told the British Broadcasting Corporation.

"We are able to give training. ... We are able to re-intervene in certain circumstances. The purpose of this has been to hand the security over from the British army to the Iraqi security forces."

Bush was joined by his top advisers, including National Security Adviser Stephen Hadley. Defense Secretary Robert Gates was traveling there separately. The mission to shore up support for the war was shared with only a small circle of White House staffers and members of the media, who were told that if news of his trip leaked early, it would be scrapped.

The White House arranged Bush's trip as a showdown nears with Congress over whether his decision in January to order 30,000 more U.S. troops to Iraq is working. Some prominent GOP lawmakers have broken with Bush on his war strategy, but so far, most Republicans have stood with Bush. In exchange for their loyalty, they want to see substantial progress in Iraq soon.

U.S. officials have been concerned about the prospect of British troops handing over control of a city where armed militias hold sway. Basra controls a key land supply line from Kuwait to Baghdad and farther north, and is also near important oil fields.

In a report last June, the International Crisis Group, a Brussels-based think tank, said Basra residents and militiamen would consider the British departure "not as an orderly withdrawal" but as "an ignominious defeat."

"Today, the city is controlled by militias, seemingly more powerful and unconstrained than before," the report said.

The report said Basra offered a "case study of Iraqs multiple and multiplying forms of violence" and a frightening picture of the country's future if coalition forces leave without power-sharing agreements among Sunnis, Shiites and Kurds to guarantee peace.

A British military statement said the operation began at 10 p.m. Sunday "with all British troops arriving at the airport by midday" Monday.

"There were no clashes or attacks on British forces during the operation. The formal handing-over of the Palaces will happen in the near future," British spokesman Maj. Matthew Bird said.

The departure of most of the remaining 500-member British force from the palace left the nation's second largest city without any multinational presence for the first time since the U.S.-led invasion of 2003.

"We told those (militias) who were fighting the British troops that the Iraqi forces are now in the palaces," Lt. Gen. Mohan al-Fireji, the Iraqi commander in the area. He said the last of the British force left about 4:30 a.m.

Iraq's defense minister said he was confident his military will be able to fill the vacuum and maintain security Basra.

"We are working very seriously to fill the security vacuum and we expect in the next few days to fill it in a good way," Defense Minister Abdul-Qadir al-Obaidi said during a stopover in Beirut, Lebanon en route to Europe.

"And I am certain that the security situation will be much better," he added, saying British forces will act "as a backup for our forces when we request it."

The Basra palace had come under near daily rocket and mortar fire from Shiite militias until the British released about 30 gunmen a few months ago and spread the word that they would soon leave.

Over the past years, Britain's ability to control events in Basra waned as the militias rose in power.

People on the streets of Basra cheered the departure of the British.

"We are pleased that the Iraqi army are now taking over the situation. We as an Iraqi people reject occupation. We reject colonialism. We want our freedom," resident Rudha Muter told AP Television News.

Another resident, Khazaal al-Nisiri, said he was confident the Iraqi army could provide enough security without the British.

"We have recently seen intensive deployment for Iraqi security troops -- this indicates that the Iraqi troops are in full control of the situation," he said. "So the British troops pullout won't cause a vacuum in the area -- our security troops are carrying out their duty well."

Following the collapse of Saddam Hussein's rule, Britain controlled security across southern Iraq, but has since handed over most of the territory to Iraqi forces.

Britain's Ministry of Defense said it hoped to hand security responsibility for Basra, the last remaining province, over to Iraqi forces sometime this autumn.

Brown has consistently refused to set a timetable for the overall withdrawal of British troops from the country, but the long anticipated pullout from the downtown palace will give the British government the option to pull out more than 500 soldiers immediately.

Ex-leader Tony Blair's decision to cut troops numbers in Iraq from 7,000 to 5,500 in February included an option of pulling out the soldiers based in the Basra palace once it was handed back to the Iraqis.

Britain's Defense Ministry said in a statement that U.S. officials were consulted over the plan, and offered assurances that there was still a large enough British presence in the area to provide security.

"The decision is an Iraqi-led initiative and is part of a coalition-endorsed process," the ministry said.

British forces will operate from Basra Air Station, but "retain security responsibility for Basra until we hand over to provincial Iraqi control, which we anticipate in the autumn," the statement said.