BARCELONA, Spain (AP) — After failing to get the job done at home against Benfica, Barcelona knows it will likely need a win at unbeaten Bayern Munich to avoid its first group-stage elimination in the Champions League in nearly two decades.

Barcelona's hopes of advancing in the top European club competition took a hit with a 0-0 draw against Benfica on Tuesday at the Camp Nou Stadium.

A win would have guaranteed Barcelona a spot in the knockout stages for the 18th straight season, but it couldn’t capitalize on its chances in what was Xavi Hernández’s coaching debut in the Champions League.

Defender Ronald Araújo thought he had scored the crucial winner in the 83rd but the goal was disallowed for offside.

Benfica had its own chance in stoppage time when Haris Seferovic got past Barcelona goalkeeper Marc-André ter Stegen but failed to find the net, sending some Benfica players and coach Jorge Jesus to the ground in despair.

The draw kept the Catalan club in second place in Group E, two points ahead of Benfica, but the Portuguese side has the tiebreaker advantage if it beats already eliminated Dynamo Kyiv at home and Barcelona fails to defeat group winner Bayern in Germany in the final round.

Bayern won 2-1 at Dynamo in the other group match Tuesday for its fifth straight victory in the competition.

“We leave with a sour taste in our mouth because we wanted to seal the qualification spot here at home in front of our fans,” Araújo said. “We played a good match but couldn’t get the goal that would have been key for us to advance. Now it’s down to the last game against Bayern, which will be complicated, but not impossible.”

Xavi, the former midfielder who helped Barcelona win four Champions League titles as a player, made his coaching debut in a much-needed win against Espanyol in a Spanish league derby at the weekend — a result that ended the team’s four-match winless streak.

“We played a great match but couldn't score,” Xavi said. “We are optimistic. We are Barcelona and will go to Munich to win that match, just like we try to do against every team. We will play with the same attitude that we played today.”

Benfica hasn’t made it past the group stage since 2016-17, when it was eliminated by Borussia Dortmund in the last 16.

Barcelona played well and looked in control from the start even though it didn’t create many significant scoring opportunities.

It was Benfica that almost broke the deadlock in the 34th with a powerful header by Roman Yaremchuck that prompted a foot save by Ter Stegen at the goal line. A couple of minutes later, a goal by Nicolás Otamendi didn't stand because Everton’s free kick cross went out of bounds in the buildup.

Barcelona answered when Yusuf Demir’s curling left-footed shot struck the crossbar in the 42nd, and in the second half Memphis Depay almost opened the scoring in a breakaway in the 57th.

Ousmane Dembélé, coming off an injury, came off the bench in the 66th and quickly set up a header by Frenkie de Jong that prompted a difficult save by Benfica goalkeeper Odisseas Vlachodimos. Dembélé also had a chance in a one-on-one situation in the final minutes but couldn't get a shot on goal as Otamendi came in to deflect the ball away.

“The team played well in a difficult game against a Barcelona side that has a new coach and a new ambition," Otamendi said. “We could have won, we could have lost, but we played a great game and I’m happy for the team. Now we have a final at home and we will try to play to win and try to qualify.”

Barcelona, in its first season without Lionel Messi in nearly two decades, became in danger of elimination after opening with consecutive 3-0 losses to Bayern and Benfica. It recovered thanks to two straight 1-0 wins over Dynamo.

Benfica's win over Barcelona in their first match was the first in six decades for the Portuguese side against the Catalan club.

Xavi was without Sergi Roberto because of an injury, while Sergiño Dest, who also had been nursing an injury, started on the bench.

___

More AP soccer: https://apnews.com/hub/soccer and https://twitter.com/AP_Sports