Taiwan President Tsai Ing-wen resigned as chairperson of the ruling pro-independence Democratic Progressive Party (DPP) on Saturday after it suffered a major electoral setback, losing two of the island's most important posts in mayoral elections.
The results of the polls, being held a little more than a year ahead of Taiwan's next presidential elections, will be closely watched in China, which claims self-ruled and proudly democratic Taiwan as its own and which has ramped up pressure on Tsai and her administration since taking office in 2016.
In the run-up to the elections, Tsai and her government repeatedly said China was attempting to sway election results with its "political bullying" and "fake news", accusations that Beijing denied.
But the DPP lost control of the mayoralties in Taiwan’s second-most populous city Taichung and the key battleground of Kaohsiung in the south, which it had held for two decades and played a central role in Taiwan's pro-democracy movement in the 1970s.
Both were won by the China-friendly opposition, the Kuomintang, which once ruled China before fleeing to Taiwan at the end of a civil war with the Communists in 1949.
Tsai said the DPP would reflect on the defeat, but she vowed to press on.
"Continuing reforms, freedom and democracy, and protecting the country's sovereignty are the mission that the DPP would not abandon," she told reporters.
She said she would not accept the resignation of her premier William Lai, who had offered to quit earlier in the evening.
The DPP held on in two of its other strongholds though: Tainan in the island's south and Taoyuan in the north.
"This is a tragic defeat for the DPP," Yao Chia-wen, a senior adviser to the president, told Reuters.
"But this is not support for the Kuomintang from the people. This is the people's disappointment in the DPP," he said, citing slower-than-expected initiatives that have drawn criticism including pension and justice reforms.
Votes are still being counted in Taiwan's affluent capital Taipei, where the incumbent mayor Ko Wen-je, an independent, is in a close race with the Kuomintang's Ting Shou-chung, and the DPP is running a distant third.
There was no immediate reaction from China to the election results.
Taiwan television stations reported a high turn out, with some polling stations in parts of Taipei and Kaohsiung remaining open past 4pm (0800GMT) when the polls were supposed to close.
Candidates fanned out across the island to press the flesh and canvass votes, and held noisy, colourful rallies that have become the hallmarks of Taiwan's vibrant democracy, in marked contrast to China where the Communist Party tolerates no dissent to its rule.
Tensions across the Taiwan Strait have heightened with China conducting military drills around the island and snatching away Taiwan's dwindling number of diplomatic allies.
Tsai's domestic reform initiatives, from the island’s pension scheme to labour law, have also come under intense voter scrutiny recently.
Confidence in the government has waned in recent months after reform moves upset both the opposition and some supporters, who said Tsai had backed away from promises to reduce the deficit and cut pollution.
Underscoring Tsai's challenge are a series of public votes also held on Saturday on whether to make same-sex marriage legal, an issue which has deeply divided Taiwan.
"This is a small step for myself, but a big step for mankind," Chi Chia-wei, a veteran gay rights activist who had petitioned Taiwan's constitutional court to take up the issue, told Reuters after he voted.
Tsai has made little progress despite campaigning on a promise of marriage equality in the run-up to elections in 2016.
In Asia's first such ruling, Taiwan's constitutional court declared in May last year that same-sex couples had the right to legally marry, and set a two-year deadline for legalisation.
Voters will also be asked whether the island should join the 2020 Tokyo Olympics as Taiwan, rather than "Chinese Taipei" – the name agreed under a compromise signed in 1981.
A vote to compete under a Taiwan banner would further rile Beijing, which has never renounced the use of force to bring the island under its control.
Results for the referendum votes may not come out until the early hours of Sunday morning, according to election officials.