MADRID (AP) — After its third stumble in a week, there’s suddenly reason for concern at Real Madrid.

Madrid lost 2-1 at Espanyol on Sunday to see its 25-game unbeaten streak in the Spanish league come to an end. The defeat extended its winless run to three matches in all competitions after what had been a near-perfect start to the season.

Carlo Ancelotti’s team was coming off a shock home loss to Moldovan club Sheriff in the Champions League and a scoreless home draw against Villarreal in the Spanish league.

“We played poorly,” Ancelotti said. “There’s not much else to say. It was our worst match. We have to take a step back during the international break and think about why the team has changed its attitude this week.”

Madrid had started the season with six victories in its first seven matches overall before being held by Villarreal and losing to Sheriff. It had thrived offensively, entering the weekend with the league’s best attack with 21 goals in seven matches.

“It was a bad week,” Madrid defender Nacho Fernández said. “We have to keep working and make some adjustments, especially on defense. We have a squad that can perform much better than it did in the last three matches.”

Madrid hadn’t lost a league match since a 2-1 home defeat against Levante last season. It was unbeaten in 18 straight away games in the competition, one short of its all-time record.

Ancelotti’s squad has been marred by injuries recently and on Sunday the coach couldn’t count on Gareth Bale, Marcelo, Dani Carvajal and Ferland Mendy.

Madrid still tops the league thanks to a better goal difference than defending champion Atlético Madrid and Real Sociedad. Atlético beat Barcelona 2-0 at home on Saturday, while Sociedad was held 1-1 at last-placed Getafe on Sunday. The three top teams have 17 points from eight matches. Sevilla, which visits winless Granada later Sunday, has 14 points from six matches.

It was the second consecutive win for promoted Espanyol, which was 13th in the standings. It had won only once in its return to the first division, and only once against Madrid in the last 14 years.

“It took a tremendous effort by our team,” said Espanyol forward Raúl De Tomás, a former Madrid player. “Real Madrid always makes you work hard until the last minute.”

De Tomás opened the scoring for the hosts from close range in the 17th minute and Aleix Vidal added to the lead in the 60th from inside the area after a nice run past the Madrid defense.

Karim Benzema had a goal disallowed in the 67th for offside but found the net again in a breakaway in the 71st after clearing two defenders and sending a low shot into the corner for his league-leading ninth goal.

Eden Hazard had an 84th-minute goal disallowed because Benzema was offside.

SOCIEDAD HELD

Real Sociedad missed its chance to take sole possession of the lead with a draw at struggling Getafe, which secured its first point this season.

Sandro Ramírez put the hosts ahead in the first half and Mikel Oyarzabal equalized for Sociedad in the 68th.

It was the first time in the Spanish league that two women officials were in the refereeing crew for a match.

OTHER RESULTS

Darío Benedetto scored early in the second half as Elche beat Celta Vigo 1-0 to end a three-match winless streak.

Celta, which had won two in a row, had an 89th-minute goal by Iago Aspas disallowed because of a handball.

Arnaut Danjuma scored a goal in each half as unbeaten Villarreal beat Real Betis 2-0 at home.

Sunday’s results dropped struggling Barcelona to ninth place in the 20-team standings.