Three decades after seizing power in a military coup, part of the 72-year-old former general's appeal to the electorate in Africa’s biggest economy lay in his successful rebranding as a man who embraced democracy.
A good deal of that rebranding happened online, where campaigning from smartphones can build momentum at low cost.
"The digital strategy has been a lifeline of the campaign for young people. We needed to create an image that enabled people to connect with him," Adebola Williams, the 29-year-old whose Lagos-based communications company, StateCraft, orchestrated Buhari's digital drive, told Reuters.
Even the doubters conceded that they had seen campaign material online.
"There were a lot of discussions on their Facebook pages, but I am not sure that really influenced me," said Endurance Dauda, 24, a student in the northern city of Kaduna, who said many of her friends are not online.
While not everyone was convinced the online methods swung their vote, the potential is hard to argue with.
Africa’s most populous nation - with 170 million inhabitants - has some of the world's highest levels of mobile phone ownership. There are 127 million mobile phone subscriptions in Nigeria, the International Telecommunications Union says.
"In the last four years it has become a lot easier and cheaper to get the Internet on your phone. It isn't exclusive anymore," Williams said, arguing that going online is no longer a luxury, despite most Nigerians living on less than $2 a day.
Defeated president Goodluck Jonathan's team also used social media, including YouTube videos highlighting Buhari’s autocratic past and facets of Jonathan’s life. In one, he was seen exercising with a personal trainer and playing squash.
But possibly more significant than the online campaigning was the use of biometric machines to identify voters, which prevented the ballot-box stuffing and multiple voting that characterised past polls.
"The card reader played a constructive role in deterring individuals who, in the past, have tampered with the electoral process either through ballot stuffing or tampering with the election results," said Dr Christopher Fomunyoh, of the National Democratic Institute for International Affairs, a non-governmental organization that promotes democracy.
As a result, this election was judged Nigeria's freest and fairest election yet.
"Fortune favors the bold. Deciding to go hi-tech was absolutely the right thing to do," U.S. Ambassador James Entwistle said after the poll.
Once the biometric aspect of election technology had been proven, there was only way for the victor to celebrate.
When Buhari got the call from Jonathan conceding defeat, Williams used his phone to capture the moment and share the image on Twitter and Instagram.
(Additional reporting by Felix Bate; Editing by Tim Cocks and Alison Williams)