Goals in either half from Rainford Kalaba and the Chinese-based James Chamanga earned Herve Renard's side, who went into the game footing Group D, a place in the quarters along with Cameroon, who drew 2-2 with Tunisia over in Lubango.
Zambia's reward for topping the table was a last eight match up with Group C runners-up Nigeria. Renard said: "When we came to Angola we said we will qualify for the quarter-finals but people were laughing at us. Against Nigeria, our target is to reach the semi-final."
Zambia skipper Chris Katongo added: "It's a great moment for me as a captain to reach the knockout stage of the Nations Cup. We have achieved something, broken the barrier, which a lot of people thought was impossible." Katonga's Gabon counterpart Daniel Cousin cut a sad figure. "We thought we had qualified but after a short while, we received the news that we did not qualify," he said. "We started well against Cameroon (in their first match), but whatever happened, happened."
Zambia burst out of the blocks in Benguela as befitted a team that needed the three points to escape the clutches of Group D - whereas the Daniel Cousin-captained Gabon required just a solitary point. On 11 minutes Zambia had their first major opportunity after a neat move involving Felix Katongo and Jacob Mulenga only for the Utrecht striker to shoot high over the woodwork. The Gabon defence was under pressure for the first real time in the tournament as Zambia maintained their energetic start.
By far the more menacing of the two sides Zambia's South Africa-based Felix Katongo, brother of skipper Chris Katonga, squandered another gilt-edged opportunity when he scuffed the ball from in front of goal. Zambia took a deserved lead in the 28th minute when defender Kampamba slid the ball upfield to Kalaba and the Uniao Leiria midfielder kept his cool to knock the ball from the left of the box past the onrushing Gabon keeper Ebang Ovono. It was the first goal Gabon had conceded since arriving in Angola.
At the break, with Tunisia leading Cameroon 1-0 in Lubango, it was the Tunisians and Zambia who were set to march on. But with Cameroon levelling shortly after the break that put them in a three way tie with Zambia and Gabon on four points, with Gabon the ones to miss out.
Herve Renard's Zambia, twice Africa Cup of Nations' runners-up, emerged for the second half intent on killing off the tie. Lax defending led to Zambia's second goal with Mulenga fighting off Gabon defender Moise Brou to cross the ball from the near post to the waiting Chamanga with the forward tapping in to an open goal.
With news filtering through that Tunisia had retaken the initiative over in Lubango, it meant the Tunisians and Zambia went through with Gabon missing out on their head to head record. But Cameroon's leveller in Lubango left them going through with Zambia.
Zambia had to survive a nerve tingling final eight minutes after Gabon got back into the match when Hull City striker Cousin floated in a high ball from the left flank for substitute Fabrice do Marcolino to shoot past Ovono. The Zambians will be without the services of suspended Chintu Kampamba for the quarters after the defender picked up his secoond booking of the competition.