MADRID (AP) — It took a goal near the end for Athletic Bilbao to finally get the better of Real Madrid and reach the Copa del Rey semifinals for the third straight season.

Álex Berenguer scored in the 89th minute to give Athletic a 1-0 victory in the quarterfinal at San Mamés Stadium on Thursday, ending a three-match losing streak for the Basque Country team against Madrid.

It was the fourth meeting between the clubs in two months, with Madrid winning in the final of the Spanish Super Cup last month in Saudi Arabia and twice in Spanish league matches in December.

Athletic reached the last two Copa finals, losing to Basque Country rival Real Sociedad in 2020 and Barcelona last season. It eliminated Barcelona in the semifinals of the Spanish Super Cup this season.

“We are proud because it's very hard to eliminate Barça and Madrid like this,” Athletic coach Marcelino García Toral said. “But there is still a long way to go. It's not because we got past two powerhouses that we are already in the final.”

Madrid, the only top club still left after Barcelona and Atlético Madrid were eliminated in the last 16, hasn't made it to the semifinals since 2018-19, when it lost to Barcelona. It hasn't won the competition since 2014.

“It hurts because we wanted to win everything,” Madrid coach Carlo Ancelotti said. “Hopefully this will make us stronger.”

Real Betis earlier Thursday won 4-0 at Sociedad and returned to the last four for the first time since 2018-19.

Madrid was without striker Karim Benzema because of a muscle injury, but Vinícius Júnior, Rodrygo and Casemiro — who arrived from international duty with Brazil on Wednesday — were in the starting lineup. Vinícius was substituted early in the second half.

Madrid struggled in attack without Benzema and with Vinícius far from his best form. It was a bad pass by Casemiro in defense that led to Athletic's late winner — a well-placed shot by Berenguer from inside the area.

On Wednesday, 2019 champion Valencia reached its second Copa semifinal in four years by defeating Cádiz 2-1, while Rayo Vallecano made the last four for the first time in four decades by beating Mallorca 1-0.

BETIS ROUTS SOCIEDAD

Betis advanced thanks to three goals by former Sociedad players.

Juanmi scored twice in the first half and Willian José added the third after halftime before Aitor Rubial closed the scoring near the end of the match at Anoeta Stadium.

Sociedad, which was also eliminated by Betis in the round of 16 last season, missed several good chances early on and had a goal disallowed for offside after a video review that drew controversy as the wrong image -- one which apparently showed the Sociedad player onside -- was shown on the television broadcast.

The company behind the VAR technology in the Copa del Rey said it was investigating what happened.

“The correct image was used by the VAR to make the correct decision,” it said in a statement. “However, the issue resulted in the wrong image being sent to the television broadcaster, which was quickly rectified. Hawk-Eye Technical Services are evaluating different scenarios to determine where the issue occurred.”

Sociedad was looking for its second Copa title in three seasons after lifting its second trophy in the competition in 2020.

Manuel Pellegrini's Betis has won four in a row in all competitions while outscoring opponents 14-2. It sits third in the Spanish league, 10 points from leader Madrid and six points from second-place Sevilla.

“We want to keep fighting for everything,” Pellegrini said.

The draw for the two-legged Copa semifinals will be on Friday.

___

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

___

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