The Nationalists (Kuomintang or KMT) won 50.96% of votes, giving them 14 out of 23 county and city magistrate posts across the island, said the Central Election Commission on Saturday.
The DPP won 41.95% of votes and grabbed six seats. The remaining three seats went to KMT allies.
The chairman of Taiwan's ruling party resigned when the results became clear.
Su Chen-chang, the DPP chairman, told reporters: "The contest is over ... it is a severe setback for the DPP, also a warning from the people to the DPP. We must humbly receive review the results.
"We took six constituencies. I hereby resign to shoulder full responsibility."
Chen Shui-bian, Taiwan's president, and the DPP's approval rating has dived because of a corruption probe into a subway project in the city of Kaohsiung involving the president's former deputy chief of staff.
The election loss is likely to weaken President Chen's mandate in the remainder of his presidency, which ends in 2008, analysts said. Chen did not make a public appearance on Saturday.
President Chen's mandate is
likely to weaken after the results
Chen has tried to consolidate his core pro-independence support base with anti-China rhetoric at election rallies, warning voters that a victory by the KMT, which favours closer ties with Beijing, would undermine Taiwan's sovereignty.
China claims the self-ruled island of 23 million as its own - to be brought back to the fold by force if necessary.
The DPP advocates a separate identity for Taiwan, whereas the KMT and its allies oppose Taiwanese independence.
In the KMT camp, opposition party leaders celebrated their first landslide election victory since losing two successive presidential races to Chen in 2000 and 2004.
The KMT triumphed even in traditional DPP strongholds such as Taipei County, Taiwan's biggest constituency where the DPP has ruled for 16 years.
Ma Ying-jeou, the chairman of KMT and widely expected to be the opposition's standard bearer in the 2008 presidential race, said: "The KMT did not beat the DPP. The DPP was defeated by itself."
The Central Election Commission said nearly 8.9 million people cast ballots, or 66% of eligible voters.