TAIPEI -Taiwan’s President Tsai Ing-wen resigned as chairman of the ruling party on Saturday (Nov 24) after it suffered an emphatic defeat in local elections seen as a midterm test of her rule.

The pro-independence Democratic Progressive Party (DPP) was trounced not only in the second largest city of Taichung, but also its long-time stronghold of Kaohsiung.

Shortly after Kaohsiung capitulated, a sombre Ms Tsai announced she was stepping down as party chairman to take full responsibility for the party's poor performance in the islandwide polls.

"Democracy taught us a lesson today, we have to meet the people's higher expectations," Ms Tsai said at a press conference at the DPP headquarters in Taipei.

Party secretary-general Hung Yao-fu also announced his resignation. He added that the party would be reorganised and an acting chairman appointed next week.

Premier Lai Ching-te, a rising DPP star, offered to resign but was ask to stay on by the president.

Observers have earlier said that the defeat of the party’s mayoral candidates at the hands of the China-friendly main opposition Kuomintang (KMT) would spell trouble for Ms Tsai’s future as party chairman and possibly her bid for a second term in the presidential election in 2020.

The loss of Kaohsiung stings the most as the DPP had ruled the port city since 1998 and its residents have long been more pro-independence than the average Taiwanese.

KMT star Han Kuo-yu took some 828,000 votes to the 691,000 votes of DPP’s Chen Chi-mai, tallies by various Taiwanese broadcasters showed.

Mr Han, visibly exhausted from months of non-stop campaigning, pledged to reach across party lines to boost the economy of Kaohsiung, a once-thriving port city that has fallen behind.

"The people of Kaohsiung have made a brave decision," he said to loud applause from a sea of supporters who greeted him with cries of "Hello, Mayor!" as they tooted horns and waved Taiwan flags.

"I know that Kaohsiung can wait no longer. We must roll up our sleeves, set off with nothing on our backs and fight for our future.

"No city will wait for us. The challenge before us is grave. Tomorrow I will reshuffle the mini Cabinet of Kaohsiung. We will do our utmost to gather a team of talents without regard for party affiliation."

Earlier a calm Mr Chen, 53, told supporters: “I’ve called Mayor Han Kuo-yu to convey my congratulations. Let’s all work for the good of Kaohsiung together under Mayor Han."

In Taichung, central Taiwan, KMT’s Lu Shiow-yen beat incumbeat mayor Lin Chia-lung by a surprisingly large margin of 200,000 votes.

Mr Lin tearfully conceded defeat shortly before 8pm, after only about half of the votes had been counted.

“It’s my honour to have been able to serve the 2.8 million residents of Taichung,” said Mr Lin, a DPP heavyweight.

Related Story Tsai Ing-wen's winter of discontent

Related Story Why Taiwan's local polls are a window to bigger battles to come

Related Story China's shadow over Taiwan elections

Ms Lu, a 57-year-old former TV journalist, told cheering supporters: “The people of Taichung used their votes to save Taichung, to save Taiwan.”

In capital Taipei, incumbent mayor Ko Wen-je, seen as a potential presidential contender, is still locked in a neck and neck race with KMT challenger Ting Shou-chung. DPP’s Yao Wen-chih is in distant third and has earlier dropped out of the race.

The KMT retained control of New Taipei City with its candidate Hou You-yi defeating DPP heavyweight and one-time premier Su Tseng-chang by a landslide.

This means the ruling party now controls just two of Taiwan’s six municipalities - Taoyuan in the north and Tainan in the south - half the number it won in the last municipal election in 2014.

In that election, DPP swept 13 of the 22 mayoral seats at stake, including four of the six municipalities, which together account for two-thirds of Taiwan’s population of 23 million.

In contrast, the KMT celebrated a remarkable return from political wilderness only two years after losing the presidential and legislative elections to the DPP.

Besides its victories in Kaohsiung and Taichung, the party has also won at least 10 other mayoral seats, doubling the number of seats it bagged in 2014.

Some 19 million Taiwanese aged 20 and above were eligible to vote to vote in the elections, while another 600,000 aged 18 and 19 qualified for an unprecedented referendum held alongside the elections.

Campaigning began months ago and had reached a fever pitch in the run-up to the polls.

​The referendum posed 10 questions on same-sex marriage and Taiwan’s international status, among other issues, to voters. Results were expected at about 2am this (Sun) morning.