South Korea's parliament has failed to pass a motion to impeach President Yoon Suk Yeol after he suddenly declared martial law on Tuesday night.
The opposition needed eight members of the president's party to vote against him for the motion to pass.
But, in a meeting on Saturday afternoon, the ruling People Power Party (PPP) confirmed its decision to oppose it, despite enormous peaceful demonstrations outside the parliament.
Most ruling party members then boycotted the vote by exiting the chamber.
"With a total of 195 votes, the number of members who voted did not reach the required two-thirds majority of the total members," National Assembly speaker Woo Won-shik said.
"Therefore, I declare that the vote on this matter is not valid."
The impeachment motion required the support of 200 members of parliament.
Following the failed motion, the opposition said it would propose a new impeachment bill on Wednesday to be voted on next weekend.
Only one politician from the PPP, Ahn Cheol Soo, stayed in the chamber for the impeachment motion, and he joined the opposition in voting to impeach the president.
But one extra PPP politician, Kim Ye-ji, returned to the chamber moments before the vote started, and another came in after the vote had begun.
The speaker allowed the vote to remain open in the parliament for around three hours but eventually called it off.
Despite boycotting the motion, the ruling party leader Han Dong-hoon said Mr Yoon could not remain president, adding his "early resignation is unavoidable".
Thousands rally for impeachment
Late on Tuesday night, President Yoon declared martial law without warning, citing anti-state and pro-North Korean forces, but provided no evidence of any conspiracy.
He lifted it six hours later after the opposition-controlled parliament voted to block it.
Ahead of the vote, the opposition party vowed that if it failed, it would keep trying to impeach the president.
Meanwhile, thousands of people lined the street outside the National Assembly, calling for the president's removal from office and chanting "vote for it" and "hurry up".
The atmosphere was more like a music festival with loud music and lights, and a crowd extended for hundreds of metres down the main road that leads to parliament.
Police estimated at least 150,000 people were at the peaceful demonstration.
President vows to stay on
Earlier today, President Yoon finally addressed the country and apologised for his declaration of martial law, saying it was a decision made "out of desperation".
"I am very sorry and would like to sincerely apologise to the people who were shocked," Mr Yoon said.
"I will leave it up to our party to stabilise the political situation in the future, including my term of office."
He assured the public he would not declare martial law a second time, as had been rumoured, and that he would take legal and political responsibility.
In the minutes before the impeachment vote, opposition MP Park Chandae stood up in parliament and called out the name of every single ruling party lawmaker who had left, asking them to resign.
This was echoed by the thousands of protesters watching along outside the National Assembly.
Mr Park also thanked the PPP lawmaker who never left the chamber, Mr Ahn.
Mr Ahn had publicly stated his intention to vote in favour of impeachment earlier this week.