Bosnia's Serb, Muslim and Croat leaders have agreed to internationally-backed parliamentary reforms, narrowly averting a political crisis.
Bosnian Serb PM Nikola Spiric had quit in protest at the reforms
Bosnia's powerful international envoy, Miroslav Lajcak, welcomed the deal as a step towards eventual EU membership.
He had threatened to impose the reforms if agreement was not reached this week.
Bosnian Serbs had argued the reforms would cut their powers in the assembly they have shared with Muslim and Croat politicians since the end of the war.
The disagreement over Mr Lajcak's plans is said to have been Bosnia's worst since the Dayton accord ended the war in 1995.
The accord left Bosnia-Hercegovina effectively divided between a Bosnian Serb entity and a Muslim-Croat federation, linked by a weak central government.
Ultimate jurisdiction over the country was granted to an envoy appointed by the EU and the UN, who had the power to sack ministers and push through legislation.
Friday's agreement will enable talks to continue on reforming the police force - a key condition for Bosnia to meet if it is to sign a pre-membership pact with the EU.
"This is a strong positive message to Europe from Sarajevo," Mr Lajcak said.
"I am sure that the reaction of the EU will be very positive."
His reforms were aimed at strengthening the central government in Sarajevo by making it harder for lawmakers to block legislation by boycotting a vote.
Bosnian Serb leader Nikola Spiric had resigned from the post of prime minister in opposition to the reforms earlier this month.
Parliament is now expected to approve the reforms on Friday.