Boko Haram extremists have killed 41 people, including a politician, and scared hundreds from polling stations in the north east, but that did not stop millions voting across Nigeria in the most closely-contested presidential race in the nation's history.

In electoral violence elsewhere, three people including a soldier were shot dead in political thuggery in southern Rivers state and two car bombs exploded at polling stations in the south east, but no one was injured, according to police.

All the Boko Haram attacks took place in north-eastern Nigeria, where the military announced it had cleared the Islamic extremists from all major centres, including the headquarters of their so-called Islamic caliphate.

Nearly 60 million people have cards to vote and for the first time there is a possibility that a challenger can defeat a sitting president in the high-stakes contest to govern Africa's richest and most populous nation.

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 MPs to the House of Assembly, where the opposition currently has a slight edge over Mr Jonathan's party. Voting for 13 constituencies was postponed until April because of shortages of ballot papers.

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 MPs defected from Mr Jonathan's party.

Polling is continuing in some areas where new machines largely failed to read voters' biometric cards, including some areas of Lagos, a mega-city of 20 million and Nigeria's commercial capital on the Atlantic coast.

Even the president was affected. 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.

Later Mr Jonathan wiped sweat from his brow and urged people to be patient as he had been, telling Channels TV: "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."

And Nigerians exercised extraordinary restraint, waiting hours in heat that rose to 100 degrees Fahrenheit (37 degrees Celsius) in some places. Many remained after voting ended to witness the ballot count, determined to do their part to try to keep the elections honest.

Results are expected 48 hours after voting ends. If no clear winner emerges, a run-off will be held.