The capital has traditionally been a stronghold of the opposition Kuomintang, or KMT, which favours closer ties with China whose government claims Taiwan as its territory.
The KMT also held on to neighbouring New Taipei City, one of 10 cities and counties it retained in Saturday's election, according to the Central News Agency.
While not all the votes had been tallied, enough had been counted for candidates to declare victory.
Two more counties were too close to call on Saturday night.
The results overall were a modest victory for the DPP, said Chen Shihmin, a professor of political science at National Taiwan University in Taipei.
"This result will allow the DPP to be united in supporting (President) Lai Ching-te when he seeks another term in 2028."
DPP candidate Puma Shen mounted a strong challenge to incumbent Mayor Chiang Wan-an but fell short of giving the DPP its first Taipei victory since 1994.
"I know there are many people crying here. I want to thank every person who voted for me," Shen told thousands of supporters after conceding.
Shen, whom Chinese officials have labelled a separatist, said he had called Chiang to congratulate him.
With almost 90 per cent of polling stations counted, Chiang had about 53.8 per cent of the vote to Shen's 45.6 per cent.
"After a long, hard-fought democratic election, we fought together until the end, thank you everyone," a teary-eyed Chiang told supporters on Saturday night.
Initially viewed as a long shot, Shen was known for his work organising civil defence courses.
He gained attention and support while campaigning on issues such as planting more trees and making city government more responsive.
Voters on Saturday also cast ballots in a referendum to overturn a ban on nuclear power.
The proposal, which was adopted, called for using nuclear energy to boost the economy.
Supporters say additional energy sources are needed to meet the artificial intelligence industry's growing demand for electricity.
While the referendum does not specify any concrete measures to reopen nuclear power plants in Taiwan, which shut last year, it gives the government a political mandate to pursue nuclear power development.
with DPA