The electoral commission, in its final total from Zambia's 150 districts, announced that Mwanawasa had won 43 per cent of the votes cast in Thursday's election.
Michael Sata, Mwanawasa's main rival, won 30 per cent of the votes and businessman Haikande Hichilima won 25 per cent.
As he took oath, Mwanawasa appealed for national unity.
"This is not the time to settle scores. Let us all be united to build Zambia," Mwanawasa said in a swearing-in ceremony at the national assembly on Tuesday.
"In elections like this, there can never be losers. Indeed there can be never be victors."
Moments after the results were announced, Ernest Sakala, Zambia's chief justice, certified Mwanawasa's re-election and ordered the president to be inaugurated for his second term.
Under Zambian law the inauguration has to take place within 24 hours of the election results being certified.
Earlier on Monday, supporters of Sata clashed with police as rioting spread into four of Lusaka's impoverished townships.
Witnesses said police fired live ammunition into the air in the Garden township when a crowd attempted to loot shops.
Police used tear gas to control crowds in the Mandevu, Chipata and Bauleni townships as tensions mounted ahead of the announcement of final results.
Sata has accused the government of manipulating the results.
The government says that the election was run cleanly and foreign observers said that Thursday's voting was largely smooth and transparent.
But Zambians are wary after the last election, in 2001, was marred by allegations of rigging. Mwanawasa won with 29 per cent of the vote then.
The opposition had argued that economic gains in the country have not trickled down to the majority in a nation where 73 per cent live in poverty and 50 per cent are jobless.
Sata drew huge crowds in poor townships with promises of jobs and a crackdown on "bogus investors" who fail to contribute to Zambia's welfare.