
The Hungarian parliament has voted to remove President Tamás Sulyok from office, who was widely seen as a loyalist of former prime minister Viktor Orbán who lost power in April after 16 years.
Prime Minister Péter Magyar's Tisza party used its two thirds majority to steamroll through the 17th amendment to the constitution, ending the term of Sulyok and the head of the Constitutional Court Péter Polt.
It was the most dramatic day in parliament since the new government took office in early May, after its surprise landslide victory against Orbán's Fidesz party on 12 April.
Sulyok now has five days to sign the amendment - his own political death warrant - or refer it to the Constitutional Court.
If Sulyok refers it to the court, Magyar has said he will launch impeachment proceedings against him, which would suspend him from office automatically.
Another option would be to simply resign to avoid a constitutional crisis in the interest of the country, as the new government has been urging him to do.
Deputies of the now opposition Fidesz party walked out of parliament before Monday's vote, accusing the Tisza party of building a tyranny.
Fidesz argues that the amendment grants the government the arbitrary power to dismiss any public official from office, with immediate effect.
"The great irony of the situation is that Fidesz have fallen foul of their own concept of power," Péter Rona - a former opposition presidential candidate - told the BBC.
The 2011 constitution, written by Orbán's government, enshrined the principle that "the winner takes all".
In office from 2010 until 2026, Fidesz reshaped the Hungarian state to its own will, and filled supposedly independent state positions with party loyalists - using its own two-thirds majority.
The 141 Tisza deputies in parliament gave a standing ovation as the results of the vote were announced.
The amendment also removes Constitutional Court judges who are over the age of 70, and forbids deputies who have served three terms in parliament from standing again - which applies to more than half the current Fidesz deputies.
"I quite agree with the removal of the president," András Baka, former head of the Supreme Court, told the BBC.
Hungary was governed by the rule of law from 1989 to 2010, he argued. After that, Fidesz captured state institutions and created an authoritarian state.
"And it is now very difficult to break up a sophisticated authoritarian regime... which was designed to survive even after electoral defeat," Baka said.

The 17th amendment is in fact a package of many laws, intended to guide the country until a new constitution can be adopted in two or three years time.
The only part of the package he disagrees with, Baka said, is the section which prevents parliamentary deputies who have served three terms from running again.
"This limits the right of the public to vote for whom they wish," he argued.
Since the April election, Orbán's party has been in free fall, reeling from the shock defeat.
Orbán himself has hardly been seen in public, and refused to take his seat in parliament. On Monday, he left Hungary to watch the finals of the football World Cup in the US.
There is growing anger with Orbán within what is left of Fidesz. Many feel bewildered by his absence.
Gergely Gulyás, the party number two, resigned as head of the parliamentary group of the party on Monday, adding to its woes.