Taiwan has made Tsai Ing-wen its first woman president, handing her pro-independence party its first majority in the national legislature and rejecting the China-friendly party that led the self-governing island for eight years.
The result should be deeply unsettling to China, which may respond by further reducing Taipei's already limited ability to win diplomatic allies and participate in international organisations.
In a statement issued after Ms Tsai's win, the Chinese cabinet's body for handling Taiwan affairs reaffirmed its opposition to independence, but said it would work to maintain peace and stability between the two sides of the Taiwan Strait.
"Our will is as strong as a rock, our attitude unswerving on the principal matter of safeguarding national sovereignty and territorial integrity," China's Taiwan affairs office said.
Voters concerned that Taiwan's economy is under threat from China and broadly opposed to Beijing's demands for political unification resoundingly chose Ms Tsai over the Nationalists' Eric Chu, a late replacement for his party's original candidate who was seen as alienating voters.
Ms Tsai, 59, said her victory was a further show of Taiwan's ingrained democracy and its people's wish for a government "steadfast in protecting this nation's sovereignty".
She too pledged to maintain the status quo with China and said both sides had a responsibility to find a mutually acceptable means of interacting, while adding that Taiwan's international space must be respected.
She said she would correct past policy mistakes, but warned that "the challenges that Taiwan faces will not disappear in one day".
Mr Chu resigned from his party's leadership to take responsibility for the massive loss. In the final tally, Ms Tsai won more than 56% of votes, while Ms Chu had 31% and a third-party candidate trailing in the distance. Outgoing president Ma Ying-jeou is constitutionally barred from another term.
Making Ms Tsai's task easier, her Democratic Progressive Party won 68 seats in the 113-member national legislature that has been traditionally dominated by the Nationalists, who took 36 seats, with the rest won by independents and smaller parties.
Illustrating the extent of their defeat, the Nationalists had won 64 seats four years ago. The new legislature convenes next month while Ms Tsai will be inaugurated in May.
The United States, Taiwan's most important ally and source of defensive arms, congratulated Ms Tsai. "We share with the Taiwan people a profound interest in the continuation of cross-Strait peace and stability," US state department spokesman John Kirby said.
Ms Tsai said one of her top priorities would be to unite Taiwan in order to gain strength and respect from abroad.
Addressing a thin crowd of a few hundred supporters at his campaign headquarters, Mr Chu said: "We failed. The Nationalist Party lost the elections. We didn't work hard enough."
He followed his concession speech by making a long bow.
Ms Tsai has proposed to open 200,000 units of affordable housing in eight years. Her party suggested in May that Taiwan's laws should change to raise wages and cut working weeks from 84 hours a fortnight to 40 hours a week.
She also reaffirmed Taiwan's sovereignty claim over East China Sea islands also claimed by China but controlled by Japan. She said Taiwan would also work to lower tensions in the South China Sea, where Taiwan, China and four other governments share overlapping territorial claims.
Ms Tsai said she would work to recruit talented people to her cabinet, increase the competitiveness of Taiwan's export-oriented economy and safeguard the food supply following a series of scandals.
Her win will introduce new uncertainty in the complicated relationship between Taiwan and mainland China, which claims the island as its own territory and threatens to use force if it declares formal independence.
"Taiwan and China need to keep some distance," said Willie Yao, a computer engineer who said he backed Ms Tsai. "The change of president would mean still letting Taiwanese make the decision."
Ms Tsai has refused to endorse the principle that Taiwan and China are parts of a single nation to be unified eventually. Beijing has made that its baseline for continuing negotiations that have produced a series of pacts on trade, transport and exchanges.
Observers say China is likely to adopt a wait-and-see approach, but might use diplomatic and economic pressure if Ms Tsai is seen as straying too far from its unification agenda.
The Taiwan affairs office reiterated its insistence on the "one China principle".
"We are willing to strengthen contact with any political party or social group that agrees that the two sides of the Strait belong to one China," it said.
Taiwan was a Japanese colony from 1895 to 1945, and split again from China amid civil war in 1949.