Gordon Brown and Nuri al-Maliki have said British troops will have 'completed their tasks' in the first half of 2009 and will then leave Iraq.
Gordon Brown and Nuri al-Maliki released the joint statement following a meeting in Baghdad.
Mr Brown arrived in Baghdad this morning for talks with his Iraqi counterpart during a previously unannounced visit.
Mr Brown met vice-presidents Adil Abdul-Mahdi and Tariq al-Hashimi before his meeting with the Iraqi PM.
The Iraqi cabinet has drafted a law that paves the way for Britain's 4,100 troops to withdraw by the end of July, more than six years after the US-led invasion.
The law setting out the terms for the British withdrawal also covers the remaining Australian, Estonian, Romanian, Salvadoran and NATO troops, and must be approved by the Iraqi parliament.
It sets the end of May as the final date for combat operations and end-July as the withdrawal date.
Britain has said it will immediately transfer helicopters from Iraq to Afghanistan, helping transport its 8,300 troops based there around the battlefield, but there are no plans to increase troop numbers at this stage.
British defence sources say it has become almost impossible to sustain military operations in two theatres, with its relatively small army severely overstretched.
Shortly after Mr Brown met the Iraqi Prime Minister, two bomb blasts in Baghdad killed 18 and wounded 53.
