Joao Cancelo and Joao Felix scored in each half to earn Barcelona a 2-1 comeback win at home against Porto on Tuesday that booked their spot in the Champions League knockout rounds for the first time in three seasons.
The visitors wasted several chances before Pepe put them in front in the 30th minute with a close-range strike from a rebound, but Barca hit back quickly, with a fine curling shot into the top corner by Cancelo two minutes later.
Cancelo was excellent running down the left channel and teed up Joao Felix for a tidy first-time finish in the 57th minute to secure the win.
Barcelona are top of Group H on 12 points, three ahead Porto and Shakhtar Donetsk who will play each other on the final matchday to decide who will join Barca in the knockout stage.
Borussia Dortmund booked their spot in the Champions League last 16 by beating AC Milan 3-1 at the San Siro in a lively Group F clash on Tuesday.
Marco Reus, Jamie Bynoe-Gittens and Karim Adeyemi were all on target to help Dortmund top the group on 10 points, with Paris St Germain, who drew 1-1 against Newcastle United, second on seven.
Milan, bottom on five points from five games, can still secure a top-two finish if they win at Newcastle and Dortmund beat PSG in the final round of games next month.