TAIPEI, Taiwan — The president of Taiwan resigned as leader of her party Saturday night after it suffered stunning local election defeats to the opposition Kuomintang, which favors closer ties with China.

The self-ruled island’s political landscape was shaken up by voters who delivered a sharp rebuke to President Tsai Ing-wen’s governing Democratic Progressive Party, or D.P.P., in elections contesting more than 11,000 seats from city mayors to neighborhood wardens. The results of the election, which was seen as a referendum on Ms. Tsai’s first two years in office, have given the Kuomintang a new lease on life and complicated Ms. Tsai’s bid for re-election 14 months from now.

Shortly after it became apparent that the D.P.P. would lose crucial mayoral races, Ms. Tsai resigned her position as party leader, raising the possibility that she would be challenged for her party’s nomination for the presidential election in January 2020.

“As this party’s chair, I take full responsibility for the outcome of today’s local elections,” she said at a hastily assembled news conference at D.P.P. headquarters in Taipei. “People believe in democratic values — today democracy taught us a lesson.”