Peter Mutharika was declared victor on Monday after an injunction barring the release of the results was lifted.
Mutharika won the ballot with 38.57 pc of the vote, against Lazarus Chakwera of Malawi Congress Party on 35.41 pc.
Mutharika was speculated to have died during the campaign after he cancelled a series of appearances.
Malawi's President Peter Mutharika on Tuesday urged opposition parties to accept the outcome of an election clouded by fraud allegations as he was sworn in for a second term.
Thousands of supporters gathered at a sports stadium in Malawi's commercial capital Blantyre to watch him take the oath of office, which had been announced just hours earlier.
Mutharika, 78, of the ruling Democratic Progressive Party (DPP), was declared victor on Monday after an injunction barring the release of the results was lifted.
"I want to congratulate other leaders who competed with me in these elections. But they have to accept that there can only be one winner," Mutharika declared in a short speech.
"The elections are over. This is a time to unite and develop this country."
Mutharika won the ballot with 38.57 per cent of the vote, against former evangelist Lazarus Chakwera of the Malawi Congress Party (MCP) on 35.41 per cent—a gap of just 159,000 votes.
Turnout was 74 per cent of 6.8 million registered voters.
Temporary injunction
The MCP, the main opposition party, had obtained a temporary injunction at the weekend to halt the release of results over alleged vote-rigging, but it was later lifted by the courts.
Mutharika dismissed any doubts over the outcome, saying international observers had deemed the May 21 election "peaceful, free and fair."
"It is the victory of the rule of law and the rule of democracy. Democracy has won," he said.
Mutharika was speculated to have died during the campaign after he cancelled a series of appearances.
In a swipe at the rumours, he opened his speech saying "I did not die"—triggering loud applause from party supporters.
Chakwera and the MCP have not responded since the results were declared.
MCP spokesman Eisenhower Mkaka said on Saturday the party had turned to the courts because of "very glaring irregularities".
Some documents showed "the same handwriting coming from different polling stations which are miles apart," he said, adding there was a lot of correction fluid on result sheets.
Mutharika campaigned for a second five-year term on his record of improving roads and power infrastructure in the impoverished southeast African country.
In his first term of office, inflation fell from 23 percent to below nine percent, but still just one in nine of the population have access to mains electricity. The DPP also won parliamentary elections held on the same day last week.
DPP campaign director Ben Phiri told AFP that the election outcome illustrated that the DPP was the "capable party".
"People said we would lose these elections and we are written off from the beginning," he said.
A separate presidential inauguration ceremony is planned at the same venue on Friday.
Mutharika, a former law professor in the US, came to power in 2014 vowing to tackle corruption after the "Cashgate" scandal a year earlier revealed massive looting from state coffers.
But he has faced corruption allegations himself.
Last November, he was forced to return a $200,000 donation from a businessman facing corruption charges in a $3-million contract to supply food to the Malawi police.
Malawi won independence from colonial ruler Britain in 1964, and was then ruled by Hastings Banda as a one-party state until the first multi-party elections in 1994.