Porto beat Leipzig 3-1 to reach second place in Group G of the Champions League on Wednesday.
Hector Herrera put the Portuguese hosts ahead early in the first half before Timo Werner came off the bench to equalise for Leipzig just after half-time.
Danilo broke the deadlock later in the second half and Maxi Pereira sealed Porto's victory in injury time.
Porto reached six points from four matches, two points more than Leipzig but four fewer than Besiktas -- held 1-1 by Monaco in Turkey in the group's other game Wednesday. Last-place Monaco have two points.
Leipzig beat Porto 3-2 in Germany. Porto next play at Besiktas, while Leipzig are at Monaco.