The then group leaders started on the wrong footing as Leon Balogun failed to deal with a routine back pass.
Madagascar scored their first goal in the 13th minute following a defensive blunder by Leon Balogun which saw Lalaina Nomenjanahary snatching the ball to score their first goal.
The Eagles missed some scoring chances and failed to respond adequately to the Madagascar.
Samuel Kalu fluffed a great pass by Ahmed Musa in the 19th minute.
Musa himself, left with the goalkeeper to beat as a pass found him in the penalty box, bungled with a poor first touch.
His subsequent attempt to dribble the goalkeeper failed.
In the second half, instead of working hard to get on level terms in no time, Nigeria quickly found themselves further behind.
That was when substitute Wilfred Ndidi deflected a free-kick by Carolus Andrea past a wrong-footed goalkeeper Ikechukwu Ezenwa.
A deep soul–searching is now imminent in the Nigeria camp after such a flat performance.
This is the first time Madagascar would be participating the Africa Cup of Nations and they are rated lower than 100th in the world.
Captain Mikel Obi, who played his 89th match for the Eagles, was a shadow of himself, while Alex Iwobi made no difference when he came on.
Moses Simon and Wilfred Ndidi brought no spark or innovation on board when they were introduced.
Madagascar finished the group stage unbeaten having scored two goals from dead-ball situations.
Eagles are expected to play their Round of 16 encounter at the same venue on Saturday.