The Sadr City fighting has killed about 1,000 people, including many civilians
The Iraqi government has agreed to a ceasefire with Shia cleric Moqtada Sadr to end weeks of fighting in Baghdad.
Moqtada Sadr's Mehdi Army militiamen are to lay down their weapons and remove snipers and bombs from roads leading into the Shia Sadr City area.
US and Iraqi forces have been trying to disarm Shia militants in the district.
The ceasefire agreement came as the Iraqi army launched a major operation in the northern city of Mosul against al-Qaeda and its allies.
The ceasefire is expected to come into effect on Sunday.
Roads to re-open
More than two million people have been trapped in Sadr City by the fighting over the last few weeks.
Access to water, food and medical supplies has been hampered by the fighting and by roads lined with snipers and bombs.
Nearly 1,000 people are believed to have been killed in the fighting, many of them civilians.
Government officials and aides to Moqtada Sadr say Mehdi Army gunmen will stop carrying their weapons in public and roads into Sadr City are to be re-opened.
Government spokesman Ali al-Dabbagh said security forces retained the right to "raid and search any place [in Sadr City] it suspects there are heavy and medium weapons".
It was not clear whether US forces would be required to leave Sadr City.
Operation Lion's Roar
Prime Minister Nouri Maliki has wanted to completely disarm Shia militias - including the Mehdi Army - before local elections in October.
But the ceasefire may also reflect the fact that the Iraqi army may need the troops committed to the Baghdad fighting to join the new offensive in the northern city of Mosul against al-Qaeda militants, says the BBC's Clive Myrie in Baghdad.
Battles on multiple fronts may still be too difficult for the Iraqi army, says our correspondent.
Around 10,000 Sunni tribesmen from Mosul who are loyal to the government are taking part in what is being called Operation Lion's Roar with an armoured brigade of Iraqi troops.
More troops are due to move into the area in the coming days.
A curfew is already in effect in the city and judges have issued a number of arrest warrants for al-Qaeda leaders.
Over the past year al-Qaeda has lost its foothold in western Iraq and the northern city of Mosul is viewed as its last urban stronghold.
The Sunni tribesmen involved in the operation were once allies of al-Qaeda but now back coalition forces.
Prime Minister Maliki has for several weeks been saying that al-Qaeda is an isolated, spent force in Iraq and that he is confident it can be driven out of the country completely.
The operation comes after Iraqi authorities mistakenly announced that the leader of al-Qaeda in Iraq, Abu Ayyub al-Masri, had been captured in Mosul.
US officials denied al-Masri had been captured, saying a man with a similar name had been detained.