Taiwan President Tsai Ing-wen waves to the supporters at the celebration of the 14th presidential inauguration on May 20, 2016 in Taipei, Taiwan.

Taiwan's ruling party was handed a major defeat in local elections Saturday that were seen as a referendum on the administration of the island's independence-leaning president amid growing economic and political pressure from China.

Soon after the results came in, President Tsai Ing-wen resigned as head of the Democratic Progressive Party. She will remain as president and her resignation will have no direct effect on the business of government, although the results bode ill for her re-election chances in two years.

Rival China said the results reflected a desire of Taiwanese for better relations with the mainland. Ma Xiaoguang, the spokesman for Beijing's Taiwan Affairs Office, said his government will continue to treat Taiwan as part of China and "resolutely oppose separatist elements advocating 'Taiwan independence' and their activities," according to the official Xinhua news agency.

In another victory for China, voters rejected a proposal to change the name of its Olympic team to Taiwan from the current Chinese Taipei. They also approved a referendum opposing same-sex marriage in a setback to LGBT couples, though ballot initiatives in Taiwan are non-binding.

The DPP lost the mayoral election to the Nationalist party in the southern port city of Kaohsiung, where it had held power for 20 years. The Nationalists also defeated the DPP in the central city of Taichung, home to much of Taiwan's light industry, while Ko Wen-je, the independent mayor of Taipei, the capital, narrowly won a second term. The Nationalist candidate in Taipei has asked for a recount.

At a brief news conference at DPP headquarters late Saturday, Tsai announced she was stepping down as DPP chair and said she had refused Premier William Lai's resignation, saying she wanted him to continue her reform agenda.

"Today, democracy taught us a lesson," Tsai said. "We must study and accept the higher expectations of the people."

The elections for mayors and thousands of local posts were seen as a key test for Tsai's 2-year-old administration, which has been under relentless attack from Beijing over her refusal to endorse its claim that Taiwan is a part of China.

Tsai and the DPP won a landslide victory in 2016, but China swiftly responded by cutting all links with her government. Beijing has been ratcheting up pressure on the island it claims as its own territory by poaching its diplomatic partners and barring its representatives from international gatherings, while staging threatening military exercises and limiting the numbers of Chinese tourists visiting Taiwan.

The Nationalists, known also as the KMT, had campaigned on their pro-business image and more accommodating line toward Beijing.

Since her election, Tsai has walked a fine line on relations with China, maintaining Taiwan's de facto independent status that the vast majority of Taiwanese support, while avoiding calls from the more radical elements of her party for moves to declare formal separation from the mainland.

Taiwanese officials had warned that Beijing was seeking to sway voters through the spread of disinformation online similar to how Russia was accused of interfering in U.S. elections.

Although domestic concerns were in the foreground, China played a major factor in voter sentiment, analysts said.

"I think part of the reason for the vote on Saturday was concern about relations between Taiwan and mainland China," said Huang Kwei-bo, vice dean of the international affairs college at National Chengchi University in Taipei. "Their relations have slid backward."

Saturday's results also throw Tsai's political future into question. While the DPP still controls the national legislature, local politicians are crucial in mobilizing support among grass-roots supporters.

"I'm afraid it will be a big challenge for her in 2020," said Gratiana Jung, senior political researcher with the Yuanta-Polaris Research Institute think tank in Taipei.

Economic growth, employment and pension reforms were among key issues in the elections, which drew high turnout from the island's 19 million voters. Government employees who feel slighted by pension cuts that took effect in July probably mobilized against Tsai's party, Jung said.

Nationalist Party Chairman Wu Den-yih told reporters Saturday that his party would keep trying to avoid diplomatic friction with China and ensure smooth two-way trade.

"We hope the two sides will soon go back to a peaceful and stable trend in relations," he said.

Chiang Kai-shek's Nationalists rebased their government to Taiwan in 1949 amid the civil war with Mao Zedong's Communists. They ruled under martial law until the late 1980s, when the native Taiwanese population began to take political office, mostly through the DPP.

The vote against changing the name used in international sporting events to Taiwan was seen as a test of support for independence. It was symbolic in nature, as the International Olympic Committee had ruled out a name change, which would be opposed by China.

Though referendums are only advisory, the vote in favor of restricting marriage to male-female couples will likely put lawmakers in a difficult position. They face both a court order to make same-sex marriage legal by 2019 and elections in 2020.