The 76-year-old leader waved at hundreds of jubilant supporters in his home town of Daura, in the northwestern Katsina state, where he will vote on Saturday.
Buhari, from the All Progressives Congress (APC), is expected to face a stiff challenge from former vice-president Atiku Abubakar, 72, from the Peoples Democratic Party (PDP).
Abubakar is a fellow Muslim from Adamawa state, in northeast Nigeria.
Buhari arrived at the Daura mosque in a festival atmosphere, with crowds cheering his convoy and security detail.
Inside, the Emir of Daura, a traditional ruler, told the congregation: “I call on all people of Daura to come out en masse tomorrow and vote.”
Buhari enjoys fanatical support in his home town and across the wider north, where he is seen as a humble man of the people, unlike Abubakar who is viewed as an elite businessman.
Security was tight in Daura and in the northwest, with armed personnel present at several new checkpoints after a spate of attack by bandits on local communities.
As election officials transported ballot boxes and voting equipment to polling stations around the country, millions prayed for a peaceful vote.
In Lagos, some 1,000km from Daura in the southwest, the imam at the city’s Central Mosque said: “We are pleading for God’s protection for all of us at this important moment.”
He called on the hundreds listening to show “peace of mind”, adding: “When you see them snatching ballot boxes, stealing or scattering, I’m saying now… don’t be a part of them.”
Fatu Aluko, a market trader near the mosque on Lagos Island, said she felt the result was in “God’s hands”.
Religion plays a key role in Nigerian life, including its politics. The country is almost evenly split between a mainly Muslim north and a largely Christian south.
Buhari’s Vice-President Yemi Osinbajo is a church pastor while Abubakar’s running mate, Peter Obi, is a devout Roman Catholic, whose sister is a nun and brother is a priest.