Nearly 90 million people were eligible to vote for President Muhammadu Buhari's successor, with many Nigerians hoping their new leader would tackle a widening security crisis, the sluggish economy and growing poverty.
For the first time since the end of military rule in 1999, a third serious candidate has emerged to challenge the dominance of the ruling All Progressives Congress (APC) and the main opposition Peoples Democratic Party (PDP).
The race sees former Lagos governor and APC candidate Bola Tinubu facing PDP's Atiku Abubakar, a former vice president, and surprise third party candidate, Labour's Peter Obi.
Crowds gathered to watch counting in some polling centres, where officials were observed by party representatives. Tallies were counted by hand before they were sent on electronically.
"We have to stay and watch," said Chinoso Ekpei, 27, a contractor, waiting with a crowd of dozens for the tally at their polling station in Ikoyi, Lagos. "We have to focus, we don't know what they did last time."
PDP's candidate Abubakar claimed fraud when he was beaten by Buhari in the 2019 vote before the Supreme Court dismissed his lawsuit.
Independent National Electoral Commission (INEC) said vote counting started where the voting had ended but has not said when official results will be released.
Thugs disrupted polling at some voting stations, but the election was mostly peaceful in a country where attacks and ethnic tensions marred past votes.
But angry voters protested after INEC started late or problems with identification technology disrupted voting in several centres in Lagos, southern Port Harcourt and the northwest state of Kano.
"INEC didn't arrive on time and they're not organised. I want to vote. We are tired, we need change," said Chikezae Okafor, 41, a health and safety officer in Port Harcourt.
Voting was scheduled to end at 1330 GMT though INEC Chairman Mahmood Yakubu said people in lines after could still cast their ballots.
In southeast Anambra State, officials counted votes at Nnamdi Azikiwe University, where crowds of voters danced and sang.
But desperation was clear in another nearby centre.
"It is not normal. I will wait all night, I came to vote and I will," said student Blessing Mbanefo, 21, waiting to vote. "I'm ready to sleep here."
Streets in Lagos and other cities were mostly calm on Saturday, as traffic was restricted. Groups of boys took advantage to hold impromptu football matches in the empty roads.
Several Lagos polling booths were ransacked, according to INEC, and voting at 141 polling units in Bayelsa would take place on Sunday after the ballot was disrupted there.
Buhari, a former army commander, steps down after two terms in office, with critics saying he failed in his promises to make Nigeria safer.
APC's candidate Tinubu, 70, a long-time political kingmaker, says "It's my turn" for the presidency. He can count on APC's structure and his political network.
He faces a familiar rival -- PDP candidate Abubakar, 76, who is on his sixth bid for the top job and touts his business experience.
But both are old guard figures who have fought off past corruption accusations.
The emergence of a surprise third candidate appealing to young voters, Labour Party's Obi, 61, has thrown the race open with his campaign as the candidate of change.
"I want Nigeria to move forward. We've been moving backward for years," said Chiobueze Otueh, voting in Anambra State. "We need someone different."
Fuel and cash shortages caused by a bank note exchange in the run-up to the election also left many Nigerians struggling more than usual in a country already hit by more than 20-percent inflation.
Voters will also cast their ballot for Nigeria's two houses of parliament, the National Assembly and Senate.
To win the presidency, a candidate must get the most votes, but also win 25 percent in two-thirds of Nigeria's 36 states.
If no candidate wins, a runoff will take place within 21 days between two frontrunners -- an unprecedented outcome that some analysts say is a possibility this time around.
The rules reflect a country almost equally split between the mostly Muslim north and predominantly Christian south, and with three main ethnic groups across the regions: Yoruba in the southwest, Hausa/Fulani in the north and Igbo in the southeast.
Voting also often falls along ethnic and religious lines: Tinubu is a southern Yoruba Muslim, Abubakar is an ethnic Fulani Muslim from the northeast, and Obi is a Christian Igbo from the southeast.
Most experts said INEC was more prepared than in 2019 with the biometric voter IDs to help prevent fraud and results transmitted electronically.
But Nigeria's security challenges are vast.
Jihadists operate mostly in the northeast, bandit militias carry out mass kidnappings in rural communities in the northwest, and separatist gunmen are accused of targeting INEC offices and police in the southeast.