Ecuador's Congress has ratified President Lucio Gutierrez's decision to sack the judges of the Supreme Court after mounting protests.
Tension has been high since Mr Gutierrez sacked the judges
Congress voted to set up a commission to appoint new members of the court, in a bid to defuse a growing crisis.
The judges were appointed by Mr Gutierrez's congressional allies in December, sparking popular discontent.
Mr Gutierrez and his opponents accuse each other of politicising the Supreme Court to their own advantage.
As the debates went on in Congress, hundreds of police kept watch over about 2,000 people protesting outside.
They were calling for the resignation of Mr Gutierrez, but he told reporters late on Sunday that there was "no possibility" of him stepping down.
Over the weekend, thousands of people marched through the streets of Quito, banging pans and demanding the president's resignation.
They defied a state or emergency imposed by Mr Gutierrez in Quito on Friday and lifted less than 24 hours later.
Protesters have accused the president of behaving like a dictator
The trouble began in December, when Mr Gutierrez first fired the Supreme Court, alleging that the magistrates were biased against him.
The new court promptly dropped outstanding corruption charges against one of Mr Gutierrez's allies, former President Abdala Bucaram.
Mr Bucaram's Roldosista Party had backed Mr Gutierrez's drive to replace the Supreme Court. The party also helped to block an opposition attempt to impeach Mr Gutierrez in November.
Opponents say dismissing the judges was part of a government deal to exonerate Mr Bucaram in return for his political support.
Popular protests have forced two presidents out of office since 1997, but it appears Mr Gutierrez has no intention of bowing to their demands, says the BBC's correspondent in the region, Hannah Hennessy.