Buhari faces a daunting to-do list, including reviving an economy still struggling to recover from a 2016 recession and quelling a decade-old Islamist insurgency that has killed thousands of people in the northeast, many of them civilians.
Buhari of the All Progressive Congress party proved wrong those who doubted he could survive the blows of recession, militant attacks on oilfields, and Islamist insurgency that blighted his first term.
He won by 56 percent compared with 41 percent for the other candidate, businessman and former vice president Atiku Abubakar of the People's Democratic Party.
The president won by 3.9 million votes, having garnered 15.2 million to Atiku's 11.3 million.
The turnout, based on valid votes, was 33.2 percent. In the 2015 presidential election, turnout was 44 percent.
A message posted on Buhari's Twitter feed late on Tuesday showed him smiling and surrounded by applauding staff at his campaign office.
"I met the very hardworking members of our team, many of them young people, and was briefed on the performance of our party so far in the Presidential Elections. I am very proud of what has been accomplished," he said on Twitter.
Garba Shehu, Buhari's spokesman, said the president's office would have no comment until the electoral commission announces the winner.
Earlier, Atiku's party demanded an immediate halt to the release of results by the Independent National Electoral Commission until turnout figures are provided to the competing parties.
Atiku's party has rejected the tallies announced so far as "incorrect and unacceptable". Buhari's party has said the opposition was trying to discredit the returns from Saturday's election.
The accusations have ratcheted up tensions in a vote marred by delays, logistical glitches and outbreaks of violence.
Nigeria's six decades of independence have been marked by long periods of military rule, coups and secessionist wars.
Observers from the Economic Community of West African States, the African Union and the United Nations appealed to all parties to await the official results, expected later this week, before filing complaints.
The candidate with the most votes nationwide is declared winner as long as they have at least one-quarter of the vote in two-thirds of Nigeria's 36 states and the capital, Abuja.
Otherwise there is a second-round run-off.
Buhari secured enough votes to meet both requirements.
Buhari, 76, is a former military ruler who took office in 2015 and sought a second term with pledges to fight corruption and overhaul Nigeria's creaking road and rail network.
Atiku, 72, had said he would aim to double the size of the economy to $900 billion by 2025, privatize the state oil company and expand the role of the private sector if voted into office.
Voting took place on Saturday after a week-long delay which the election commission said was due to its inability to get ballots and results sheets to all parts of the country.
The event - Africa's largest democratic exercise - has also been marred by violence in which at least 47 people have been killed since Saturday, according to the Situation Room, a monitoring organization linking various civil society groups.
Some of the deaths took place after gangs allied to the leading parties clashed with each other as well as the police over the theft of ballot boxes and allegations of vote fraud.
Police have not yet provided official casualty figures.
More than 260 people have been killed since the start of the election campaign in October. The toll so far is lower than in earlier elections, but the worst violence occurred previously only after results were announced.