Memphis Depay and Philippe Coutinho scored late at Villarreal as Barcelona won 3-1 and ended its winless streak in the Spanish league on Saturday.

Prior to the trip, only three other teams in the 20-team competition had earned fewer points on the road this season after Barcelona went winless in its first five league matches away from Camp Nou.

The long-awaited win came in Xavi Hernández’s third match in charge since replacing Ronald Koeman.

Barcelona's Memphis Depay celebrates after scoring his side's second goal during the La Liga soccer match between Villarreal and Barcelona in Villarreal, Spain, Saturday, Nov. 27, 2021. (AP PhotoAlberto Saiz)

Barcelona's Memphis Depay celebrates after scoring his side's second goal during the La Liga soccer match between Villarreal and Barcelona in Villarreal, Spain, Saturday, Nov. 27, 2021. (AP PhotoAlberto Saiz)

Frenkie de Jong broke through for the visitors minutes after halftime when he finished off a ball saved by goalkeeper Gerónimo Rulli.

But Villarreal equalized through substitute Samuel Chukwueze in the 76th and was pressing for a winner when Depay struck against the flow of play in the 88th.

Depay won a long goal kick by Marc-Andre ter Stegen, dribbled around Rulli and coolly put the ball between the legs of defender Pervis Estupiñán.

Barcelona's Memphis Depay takes the ball around Villarreal's goalkeeper Geronimo Rulli on his way to scoring his side's second goal during the La Liga soccer match between Villarreal and Barcelona in Villarreal, Spain, Saturday, Nov. 27, 2021. (AP PhotoAlberto Saiz)

Barcelona's Memphis Depay takes the ball around Villarreal's goalkeeper Geronimo Rulli on his way to scoring his side's second goal during the La Liga soccer match between Villarreal and Barcelona in Villarreal, Spain, Saturday, Nov. 27, 2021. (AP PhotoAlberto Saiz)

Coutinho sealed the three points in stoppage time when he converted a penalty that he earned while dribbling into the area.

Barcelona stayed in seventh place, but reduced the gap to leader Real Madrid to seven points. Madrid faces a tough test on Sunday when it hosts third-placed Sevilla.

Second-placed Real Sociedad will also visit Espanyol, while fourth-placed Atlético Madrid is at Cádiz.

Barcelona's Memphis Depay scores his side's second goal during the La Liga soccer match between Villarreal and Barcelona in Villarreal, Spain, Saturday, Nov. 27, 2021. (AP PhotoAlberto Saiz)

Barcelona's Memphis Depay scores his side's second goal during the La Liga soccer match between Villarreal and Barcelona in Villarreal, Spain, Saturday, Nov. 27, 2021. (AP PhotoAlberto Saiz)

Unai Emery's Villarreal remained 12th.

OTHER RESULTS

Rayo Vallecano continued to impress after the promoted team fought back to draw at Valencia 1-1, and ended the match pushing Valencia into its box. Rayo, which has the league’s best home record, inched into fifth place after taking the point on the road.

Barcelona's head coach Xavi Hernandez gestures during the La Liga soccer match between Villarreal and Barcelona in Villarreal, Spain, Saturday, Nov. 27, 2021. (AP PhotoAlberto Saiz)

Barcelona's head coach Xavi Hernandez gestures during the La Liga soccer match between Villarreal and Barcelona in Villarreal, Spain, Saturday, Nov. 27, 2021. (AP PhotoAlberto Saiz)

Iago Aspas and Santi Mina scored for Celta Vigo to win at Alavés 2-1 in a match that was played with an alternative yellow ball due to snowfall and wintry weather.

Mallorca and Getafe also drew 0-0 on the Balearic Islands.

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

More AP Europe sports: https://apnews.com/hub/sports-europe and https://twitter.com/AP_Sports