Muhammadu Buhari, 76, was re-elected president after a delayed poll that angered voters and raised political temperatures, but the opposition immediately vowed to challenge the "sham" result.
It was the second victory at the ballot box for Buhari, a one-time military ruler who was first elected in 2015 to lead Africa's most-populous nation and top oil producer.
He secured 56 percent of the vote against 41 percent for Abubakar, a winning margin of 3.9 million votes, according to the official results.
Abubakar, the 72-year-old candidate for the opposition Peoples Democratic Party (PDP), has now followed through with his promise to challenge the results, his lawyer Emmanuel Enoidem told reporters.
The PDP "asked that our candidate who won the election massively across the country be declared the winner of that election," he said.
Failing that, the court in Abuja was asked to set aside the election results "on the grounds of irregularities which were very apparent across the country," he added.
Enoidem said that 400 witnesses were ready to appear before the presiding judges.
The legal challenge was lodged just a day before the three-week deadline for such cases.
The court now has 180 days to pronounce on the case which could then be appealed to the supreme court.
Abubakar's official inauguration is scheduled for May 29.
Last month's vote was marred by violence, including 53 deaths, according to election observers.
Some reported vote-buying, intimidation and violence towards voters and officials, which have been a problem in previous polls in Nigeria.
At 35 percent across the country, low voter turnout was blamed on a combination of apathy because of the one-week delay, organisational problems and unrest.
EU and local observers spoke of "serious problems".
The election offered a marked contrast between the austere former general Buhari, of the All Progressives Congress (APC), against former vice-president and millionaire businessman Abubakar, who proposed to free up the economy.