BAGHDAD, Iraq (CNN) -- Britain will hand over security control of the southern Iraqi province of Basra within two weeks, Prime Minister Gordon Brown told British troops Sunday night during a previously unannounced visit to Iraq.

British Prime Minister Gordon Brown meets with soldiers in Basra, Iraq, on Sunday.

Brown landed in Basra for a meeting with Maj. Gen. Graham Binns, the commander of British troops in southern Iraq, military spokesman Maj. Mike Shearer told CNN.

Brown and Iraqi Prime Minister Nuri al-Maliki had agreed to turn over control of the province to Iraqis during a telephone call earlier in the day, Shearer said.

Brown thanked Britain's roughly 5,000 remaining troops for their efforts and courage and told them their efforts to train Iraqi security forces have left the Iraqis ready to shoulder responsibility for the security of Basra soon.

"The whole British people are proud of everything you've achieved, and I'm so grateful for everything you do," he said.

The British contingent is the second-largest coalition force in Iraq, behind the more than 160,000 U.S. troops. The troops withdrew to a base at Basra's airport, on the city's outskirts, in September.

Brown's government has announced plans to cut its force to about 4,500 by the end of December and then to 2,500 by spring.

Southern Iraq has not been as violent as Baghdad and other regions during the nearly five-year-old war.

But British troops have had to contend with a violent power struggle between Shiite Muslim militias, particularly anti-American cleric Muqtada al-Sadr's Mehdi Army and the Supreme Islamic Iraqi Council's Badr Brigade.

In November, Lt. Col. Nick Goulding said there had been a "dramatic" drop in violence in Basra since the British withdrawal to the airport.

Goulding said the violent rivalries have not increased in recent months, as had been anticipated when British troops moved out of the city center, and security forces have thwarted some militia efforts.

• Mortar attacks, a roadside bomb and a drive-by shooting killed at least nine people and wounded 17 in Baghdad Monday morning, according to an Iraqi Interior Ministry official.

Seven prisoners held at a detention center in central Baghdad were killed and nine wounded when mortars slammed into the facility, which is operated by the Iraqi Interior Ministry, according to the official.

Two mortars fell in central Baghdad's Karada district, wounding three civilians, he said. Also in the Karada district, two civilians died when gunmen fired into their car from another vehicle, according to the official.

Five people, including four police officers, were wounded when a roadside bomb exploded near an Iraqi national police convoy in eastern Baghdad's Baladiat neighborhood, the official said.E-mail to a friend