BARCELONA, Spain (AP)Barcelona couldn’t get the victory it needed at home against Inter Milan, and for the second season in a row the Catalan club likely won’t make it to the knockout stage of the Champions League.

Robert Lewandowski scored in stoppage time to help Barcelona salvage a 3-3 draw in a thrilling back-and-forth match against Inter on Wednesday, but the result did little to help Barca’s chances of advancing.

”This Champions League has been cruel for us,” Barcelona coach Xavi Hernandez said. ”Now it’s very difficult to advance. It’s a shame.”

Lewandowski kept the team alive – for now at least – with a last-gasp header after the visitors had taken a 3-2 lead with a goal from Robin Gosens in the 89th. A loss would have meant certain elimination for Barcelona for a second consecutive season in the group stage.

Barcelona is third in Group C with four points, three behind second-place Inter. Bayern Munich, which beat Viktoria Plzen 4-2 for its fourth victory in a row, has advanced with 12 points.

Inter leaves Barcelona in full control of its fate ahead of matches against last-place Plzen in Italy and then at Bayern Munich. A win against Plzen – which has lost all of its four matches in the competition this season – will be enough for the Italian side to advance.

”We played a great match against an opponent of great value,” Inter Milan coach Simone Inzaghi said. ”We created a lot, suffering all together. We could have closed the group with two games to spare. We hope to give the fans this satisfaction against Viktoria Plzen.”

Barcelona hosts Bayern before visiting Plzen. Barcelona needs to win its last two matches and hope Inter doesn’t add more than two points.

”It’s disappointing,” Barcelona captain Sergio Busquets said. ”It is a difficult group but we had to do better after all the signings we made. It’s not settled yet, but now it’s very complicated as we don’t depend on ourselves anymore.”

It would be the first time since 1999 that the Catalan club fails to advance to the knockout stage in consecutive years, coinciding with the departure of Lionel Messi to Paris Saint-Germain two seasons ago.

Failure this season would be extra disappointing for the club after Barcelona went on a spending spree to boost its squad with players such as Lewandowski and Raphinha.

Last year, Barcelona endured its worst Champions League campaign in about two decades, finishing behind Bayern Munich and Benfica in its group while going through a dire financial situation in the aftermath of Messi’s departure.

Barcelona took the lead from close range after a cross by Sergi Roberto in the 40th, but defensive mistakes proved costly for the hosts and Inter rallied with goals from Nicolo Barella in the 50th and Lautaro Martinez in the 63rd.

Inter’s first goal came after Gerard Pique let a ball go over his head as he apparently didn’t realize Barella was behind him. The veteran defender was booed by some fans at the packed Camp Nou.

Barcelona equalized with Lewandowski in the 82nd, but Inter moved ahead again through Gosens.

Goalkeeper Marc-Andre ter Stegen saved Barcelona again with a great foot save in a one-on-one situation with Kristjan Asllani in the final minutes.

Inzaghi was sent off near the end with a second yellow card after complaining to officials.

The setback comes before Barcelona visits Real Madrid in the first ”clasico” of the season in the Spanish league on Sunday. The two rivals are tied on points at the top, with Barcelona ahead on goal difference.

AP World Cup coverage: https://apnews.com/hub/world-cup and https://twitter.com/AP-Sports