BARCELONA, Spain (AP)Barcelona stumbled in its first game since a seven-week World Cup break when it was held 1-1 by Espanyol at Camp Nou in a heated Catalan derby that finished with both teams having a player sent off in the final minutes on Saturday.

Barcelona was in control of the Spanish league match from the fourth minute after defender Marcos Alonso scored with a header. But complacency by the hosts and some staunch defending by Espanyol gave striker Joselu Mata the chance to equalize with a penalty in the 73rd after he was fouled by Alonso in the box.

The game then turned testy. Referee Antonio Mateu showed a second yellow card to Barcelona defender Jordi Alba for protesting in the 78th and Espanyol’s Vinicius Souza for fouling a home player on the break in the 80th.

Mateu handed out a World Cup record 17 yellow cards in Argentina’s quarterfinal win over the Netherlands.

After 15 of 38 rounds, Barcelona will finish the year top of the league, ahead of Real Madrid on goal difference. But dropping points at home against a side just one point above the relegation zone was not in coach Xavi Hernandez’s plans.

”The draw is our fault. It was important to finish the year in the best manner possible,” Xavi said. ”Espanyol was thrilled to reach the final minutes with a shot at getting an equalizer. These are games you have to finish off.”

A moment of silence was held before the game in memory of Brazil great Pele, who passed away on Thursday.

The derby was played amid complaints by Espanyol that it was harmed by the unexpected decision by a Madrid court to temporarily lift a suspension on Barcelona striker Robert Lewandowski.

The court said Lewandowski should be allowed to play until Spain’s administrative court for sport makes a final ruling on the appeal that Barcelona lodged against his three-game suspension incurred in November.

The decision meant Barcelona was able to count on the league’s top scorer from the start of the match against its modest crosstown rival, which hasn’t beaten the powerhouse in the league since 2009. Espanyol criticized the decision, taken a day before the game, saying it caused ”irreparable harm.”

Lewandowski played a part in Alonso’s goal when he got his head on a cross and Andreas Christensen then nodded the ball back for his fellow defender to tap home.

On having to play against a full-strength Barcelona, including Lewandowski for the whole game, Espanyol coach Diego Martinez applauded his players’ toughness.

”As we say in the locker room, we are ready for anything and to compete under any circumstances,” Martinez said. ”We must be proud of these players. They are generous in helping one another and stick to the plan even when things are not going our way. The team knew how to keep a cool head and take advantage of our moments.”

Joselu had fought a solitary battle trying to win long balls against Alonso and Christensen until it finally paid off when he won an aerial challenge and was fouled by Alonso in the box. Joselu stepped up to the penalty spot and drilled his shot down the middle beyond Marc-Andre ter Stegen.

Espanyol goalkeeper Alvaro Fernandez, recalled by Martinez to the starting lineup for the first time since October, impressed with key saves down the final stretch. He stopped a header by Christensen and blocked a low shot by Lewandowski as Barcelona pressed for a winner.

”I am very happy for him,” Joselu said of Fernandez. ”He has shown his character and that he is a great goalkeeper.”

Mateu handed out 15 bookings, including the two second yellow cards, in the Catalan derby. He also used a video review to withdraw an initial red card he had shown Espanyol’s Leandro Cabrera for a possible foul on Lewandowski in the 80th.

SOCIEDAD THIRD

Real Sociedad beat Osasuna 2-0 to move past Atletico Madrid and back into third place, at nine points adrift of the front-runners.

Brais Mendez scored in the first half and Alexander Sorloth put the result beyond doubt in the 64th.

Sociedad forward Mikel Oyarzabal returned from a long injury layoff after tearing ligaments in his left knee in March.

VILLARREAL WINS

A late goal by Argentina defender Juan Foyth gave Villarreal a 2-1 win over Valencia.

Foyth only made one brief appearance to help his nation win the World Cup.

He went on as a first-half substitute for Villarreal and ended up breaking the deadlock with a header in the 88th.

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