PORTO, Portugal — With a convincing performance at home, 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 with a shot from inside the area early in the first half before Timo Werner came off the bench to equalize for Leipzig just after halftime.

Danilo broke the deadlock from close range after a free kick later in the second half and Maxi Pereira sealed Porto’s victory in a breakaway move in injury time, leaving the 2004 champions in good position to advance to the knockout stage for the second straight season.

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 has two points.

“In the first game in Germany, Leipzig surprised us as they were a team we didn’t know very well,” Herrera said. “Tonight we were better positioned and closed a lot of spaces.”

Leipzig had beaten Porto 3-2 two weeks ago.

“It was a strong game from us,” Porto coach Sergio Conceicao said. “We worked well as a unit and didn’t suffer as we did in Germany in the first meeting. We nullified our opponent’s strengths for large parts.”

Danilo appeared to be offside when he scored Porto’s second goal at the Estadio do Dragao.

Werner surprisingly didn’t make the starting lineup for Leipzig, but the 21-year-old German international made an impact as soon as he came on with a shot over goalkeeper Jose Sa from just inside the area for the equalizer.

“It was an even contest,” Leipzig defender Bernardo said. “The final score of 3-1 isn’t a good reflection of the match as a whole. Things are still very much open (in the group). We believe we are as good as our opponents and we’re going to fight to get through.”

Porto, which had lost four straight games against German clubs, lost Moussa Marega because of an injury in the 12th minute.

Porto next plays at Besiktas, while Leipzig is at Monaco.


More AP Champions League coverage: https://apnews.com/tag/ChampionsLeague