The front-runners among 14 candidates are President Goodluck Jonathan, a 57-year-old Christian from the south, and former military dictator Muhammadu Buhari, 72, from the predominantly Muslim north.
Voters also are electing 360 legislators to the House of Assembly, where the opposition currently has a slight edge over Mr Jonathan’s party.
However, Boko Haram Islamic extremists killed 41 people, including a legislator, and scared hundreds of people from polling stations in the north east of the country. Elsewhere, three people including a soldier were shot and killed in the southern Rivers state and police said two car bombs exploded at polling stations in the south east but no one was injured.
Voting for 13 constituencies was postponed until April because of shortages of ballot papers, electoral officials said.
Nigeria’s political landscape was transformed two years ago when the main opposition parties formed a coalition and for the first time united behind one candidate, Mr Buhari. Dozens of legislators defected from Mr Jonathan’s party.
Even the president was affected by the technical hitches on Saturday. Three newly imported card readers failed to recognise the fingerprints of Mr Jonathan and his wife.
Biometric cards and readers are being used for the first time to discourage the kind of fraud that has marred previous votes.
Afterwards, Mr Jonathan wiped sweat from his brow and urged people to be patient as he had been. He said: “I appeal to all Nigerians to be patient no matter the pains it takes; as long as if, as a nation, we can conduct free and fair elections that the whole world will accept.”
Most Nigerians exercised extraordinary restraint, waiting hours in heat that rose to 37C in some places. Many remained for more hours after voting ended to witness the ballot count, determined to do their part to try to keep the elections honest.
“The high voter turnout and the dedication and patience of Nigerian voters is, in itself, a triumph of Nigerian democracy,” said the national counter-insurgency spokesman, Mike Omeri.
He praised the bravery and commitment of military and security agencies that he said made the elections possible.
Struggling with power blackouts that are routine, some officials counted ballots by the light of vehicles and mobile phones.
A major campaign issue has been Boko Haram’s Islamic insurgency. The failure of Mr Jonathan’s administration to curb the rebellion, which killed about 10,000 people last year, has angered many Nigerians.
International outrage has grown over another failure – the government’s inability to rescue 219 schoolgirls kidnapped by Boko Haram nearly a year ago.