The Golden Eaglets will now have to battle either Burkina Faso or Cameroon to qualify for the FIFA U17 AFCON after they triumphed 3-2 over South Africa tonight.
The Eaglets finished as runners-up in Group B with six points, while South Africa will be third on three points, same as Zambia.
Morocco topped the group also on six points.
Nigeria will only know their quarterfinal opponents tomorrow when Burkina Faso and Cameroon slug it out in a winner-takes-all clash after both teams lost to group winners Mali.
The Eaglets beat Burkina Faso win the WAFU qualifiers last year, while Cameroon are the defending champions.
Tonight, South Africa stunned the Eaglets early in the encounter when Vicky Mkhawana hit target from a corner.
Charles Agada then drew Nigeria level with a header on 34 minutes.
But on the stroke of half time, South Africa regained the lead.
Light Eke then drew the Eagles level minutes into the second half, before Light Eke slotted home after a low cross by Agada.
Abubakar Abdullahi then delivered the all-important winner for Nigeria with an Emmanuel Michael assist.