SAN SEBASTIAN, Spain (AP) -- Real Sociedad beat second-division club Mirandes 2-1 at home Thursday in the first leg of their Copa del Rey semifinal.
Mikel Oyarzabal put Sociedad in front in the ninth minute from the penalty spot.
But Mirandes outplayed the hosts for long stretches and equalized in the 41st through striker Matheus Aias. However, Martin Odegaard restored Sociedad's advantage before halftime.
The second leg will be played in the first week of March at Mirandes.
Sociedad ousted Real Madrid 4-3 in their quarterfinal after a masterful attacking performance at the Santiago Bernabeu.
But Mirandes showed why it had bettered three topflight teams to reach the final four, keeping one of La Liga's best attacks in check for most of the match.
''We got a 2-1 win despite not playing well,'' said Sociedad coach Imanol Alguacil. ''We thought we were going to rout Mirandes, (but) ... the pressure and the responsibility was too much for me and my players. Mirandes played a great match and our nerves didn't allow us to play the match we wanted to.''
Oyarzabal coolly converted the spot kick to get Sociedad off to a good start. Cristian ''Portu'' Portugues earned the penalty when he was pushed down while trying to reach a ball in the area by Odei Onaindia.
Instead of shrinking, Mirandes increased its pressure led by holding midfielder Mickael Malsa and disrupted Sociedad's attack.
Pushed forward by left winger Martin Merquelanz, who is on loan from Sociedad, Mirandes bossed a long stretch of the first half. The home fans were already growing restless and some critical jeers were heard before Mirandes equalized.
Malsa anticipated a pass to Odegaard and won the ball from the Norway midfielder before setting up Aias. Aias' shot after he cut back to his left foot took a deflection off Nacho Monreal to leave the goalkeeper out of position.
Sociedad quickly retook the lead when Odegaard was finally able to receive the ball with space and time. He dribbled forward and struck a powerful shot that goalie Jesus Reguillos blocked. Reguillos also did well to parry Portu's follow-up attempt, only for Odegaard to drive in the rebound from close range.
The tempo slowed in the second half, but Mirandes never resorted to just defending its area.
Merquelanz fired high when a low cross reached him at the far post in the 62nd.
Oyarzabal could only redirect a lobbed pass from Odegaard into the hands of Reguillos in the 74th. Reguillos also saved a teammate from heading in an own goal in stoppage time.
''I am happy with the game my team played because we were true to ourselves; we were brave and took risks,'' said Mirandes coach Andoni Iraola. ''It is too bad we couldn't find that second goal, but the tie is wide open.''
Mirandes, a tiny club from Miranda de Ebro, a city of about 35,000 people in northern Spain, knocked off Villarreal, Sevilla, and Celta Vigo in previous rounds.
Mirandes also made a memorable cup run in 2011-12, when it reached the semifinals.
Athletic Bilbao beat Granada 1-0 at home in the other first-leg semifinal on Wednesday.
Only the semifinals are being played over two legs in the Copa del Rey this season. The other rounds are decided in one game.
More AP soccer https://apnews.com/Soccer and https://twitter.com/AP-Sports