BARCELONA, Spain (AP) — It took one of Barcelona's veterans to keep the Catalan club from facing an early elimination in the Champions League.

Gerard Piqué's first-half goal equaled a Champions League scoring mark for defenders and helped Barcelona edge Dynamo Kyiv 1-0 on Wednesday to end its losing streak and get back in position to advance to the knockout stage of the European competition.

Piqué scored his 16th Champions League goal to secure the crucial win for Barcelona, which had opened with consecutive 3-0 losses to Bayern Munich and Benfica and was in danger of not getting past the group stage for the first time since 2000-01.

“After the first two group games, with no points and no goals, this victory was so important to give ourselves a chance to be in the mix until the end of the group stage,” Piqué said.

The win put the Catalan club in third place in Group E, two points in front of Dynamo and one behind Benfica, which lost 4-0 to leader Bayern later Wednesday. Bayern reached nine points from three matches.

It was Barcelona’s second win in a row after it had won only once in six matches in all competitions.

It had been winless in five straight Champions League games, its longest run without a win since 1997. It had lost its last three Champions League matches at home for its worst streak ever in the European competition.

“We can't waste so many opportunities, we were playing for our lives,” Barcelona coach Ronald Koeman said. “We could have scored more.”

Piqué opened the scoring with a one-timer from close range after a cross by Jordi Alba across the area in the 36th minute, joining former Real Madrid left back Roberto Carlos as the top-scoring defender in the Champions League. Piqué had been tied with former Madrid central defenders Sergio Ramos and Iván Helguera with 15 goals.

“For a defender he has scored a lot of goals," Alba said of Piqué. “I gave him a nice caramel there. I asked him to thank me for it ... As a kid, he loved to go up and play as a striker so he’s a good finisher."

The 34-year-old Piqué also became the oldest Champions League scorer for the Catalan club, surpassing Sylvinho, who was 19 days younger when he netted against Shakhtar Donetsk in 2008.

Striker Sergio Aguero came off the bench in the 75th to replace Memphis Depay and make his second appearance with Barcelona since joining the club from Manchester City this season.

Barcelona had never lost more than two group-stage games since 1997-98.

Dynamo had opened with a home draw against Benfica before losing 5-0 at Bayern in a results that equaled its heaviest defeat in a UEFA club competition.

"It was a deserved win for Barcelona," Dynamo coach Mircea Lucescu said. “They beat us due to their experience and aggressive pressing. We committed errors in our half of the pitch that ended up becoming moments in front of our goal.”

Barcelona’s next match is the Spanish league “clásico” against Real Madrid at the Camp Nou on Sunday.

In the Champions League, it will visit Dynamo in November.

Only about 45,000 fans attended Wednesday's match at the Camp Nou Stadium.

___

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

___

Tales Azzoni on Twitter: http://twitter.com/tazzoni