Second-half substitute Ferran Torres scored twice to help Barcelona win at Borussia Dortmund and move up to second in the Champions League table.
In an end-to-end second half Raphinha gave Barcelona the lead, latching on to a ball in behind and drilling a shot into the far corner.
But hosts Dortmund were gifted a penalty when teenager Serhou Guirassy was pushed over by Pau Cubarsi in the penalty area.
The Guinea forward expertly converted the spot-kick, finding the bottom corner.
Torres was then in the right place to tap in after Dortmund keeper Gregor Kobel had denied Fermin Lopez.
Guirassy equalised for a second time in the closing stages as Pascal Gross passed the ball around Barcelona keeper Inaki Pena to give the forward an easy finish.
But Torres then scored the winner in the 85th minute with a low strike into the bottom corner.
A top-eight finish means teams skip the knockout play-off round and guarantees a spot in the last 16.
In the scoreless first half in Germany, Raphinha had been unable to turn in Lamine Yamal's early cross.
And moments later Marcel Sabitzer struck Julien Duranville's cutback over the bar from close range as both sides created early chances.
After the restart Guirassy had found the net by tapping in at the back post, but Jamie Gittens had timed his run too early in the build-up and the move was flagged for offside.
Watch highlights of every Champions League game from 22:00 on Wednesday on BBC iPlayer and the BBC Sport website and app.
There will also be a Champions League Match of the Day on BBC One on Wednesday, from 22:40 to 00:00.