Mahama's main rival, vice president and ruling party presidential candidate Mahamudu Bawumia, already conceded defeat in both presidential and legislative elections on Sunday to ease tensions.
The electoral commission said it had counted votes from 267 out of the country's 276 constituencies. Voter turnout was 60.9%.
Mahama, 66, is making a comeback after serving as Ghana's president from 2012 to 2016. He framed Bawumia as representing a continuation of the policies that led to Ghana's worst economic crisis in a generation.
(Reporting by Maxwell Adombila Akalaare and Bate Felix. Writing by Anait Miridzhanian and Sofia Christensen. Editing by Alex Richardson and Mark Potter)
