Barcelona are through to the Champions League knock-out stages as group winners after a 3-2 win at AC Milan.
Milan's Mark Van Bommel scored an early own goal but Zlatan Ibrahimovic fired in a leveller before Barca's Lionel Messi netted a penalty.
Kevin-Prince Boateng equalised again for Milan before Xavi struck.
Apoel became the first Cypriot team to qualify for the knock-out stages after a 0-0 draw at Zenit St Petersburg, marred by flares thrown by home fans.
Barcelona started their Group H game at the San Siro with a two-point advantage over Milan at the top of the group and took only 14 minutes to go in front as Van Bommell deflected in Seydou Keita's cross.
Ibrahimovic scored against his former club six minutes later by turning Clarence Seedorf's pass beyond Victor Valdes.
The visitors regained the lead in the 31st minute when Messi converted a harsh penalty awarded for a foul on Xavi at the second attempt, his first having been disallowed for a dummy at the end of his run-up.
Prince-Boateng scored with a solo effort in the 54th minute as he controlled the ball, flicked it beyond Eric Abidal in one movement and then fired a shot past Valdes.
Xavi scored the decisive goal 10 minutes later after pouncing on Messi's threaded pass and slotting the ball beyond Christian Abbiati's reach.
Bate Borisov are on course to finish bottom of that group as Plzen leapfrogged them with a 1-0 away win.
In Group G, Apoel's defence held firm to end Zenit's nine-match winning run at home in Europe, which was a Russian record. Despite having 21 shots at goal compared to Apoel's one, the home team were denied.
The game was temporarily abandoned for 10 minutes at the start of the second half because of flares being thrown. Zenit players and staff pleaded with fans to stop as smoke drifted around the field.
That result meant that Porto had to win to stay alive in the competition and they did, triumphing 2-0 at Shakhtar Donetsk with two late goals.
Hulk ran on to Joao Moutinho's pass and squeezed in the opener before Razvan Rat turned the ball into his own net, trying to clear a shot from Cristian Rodriguez. It sets up a qualification decider at home against Zenit on 6 December.
Valencia's 7-0 thrashing of Genk in Group E means that they face a do-or-die, final game at Chelsea, who lost 2-1 at Bayer Leverkusen.
Arsenal won Group F with their 2-1 home victory against Borussia Dortmund. Marseille's qualification hopes took a blow as they crashed to a 1-0 defeat against Olympiakos, who needed to win to maintain their qualification hopes.