Kylian Mbappe and Vincius Jnior converted penalties to help earn Real Madrid a 2-0 win at Real Sociedad after the host was repeatedly denied by the woodwork in La Liga.
Vincius put the visitors ahead in the 58th minute after an unnecessary handball by former Manchester City player Sergio Gomez gave the Madrid forward the chance to break the deadlock on Saturday.
Mbappe put the result beyond doubt in the 75th after a video review by the referee determined that Sociedad defender Jon Aramburu stomped on Vincius' foot in the box.
But before the goals, Madrid had to weather a furious attack by the Basque club that found ways through the defending champion's defense only to be turned back by the goal-frame.
"We probably didn't deserve to win," Madrid coach Carlo Ancelotti said.
"But we knew how to dig in during the worst moments. I value that sacrifice that is often tough to see on a team with the talent that this one has."
Ancelotti's side drew its other two outings in the Spanish league. Its first away victory put it one point behind leader Barcelona before it visits Girona on Sunday. Madrid opens its Champions League defense against Stuttgart on Tuesday.
More From This Section
Sociedad matched Madrid's pace and punch in a frenetic first half.
Luka Sucic hit the post twice, including a missile that rattled the crossbar in the 25th, and Sheraldo Becker also sent a ball off the crossbar.
On the other end, Madrid relied on Mbappe to provide its main threat, while Sociedad goalkeeper Alex Remiro did well to turn back an Antonio Rudiger header.
Sucic sent another ball off the post from a pass by Umar Sadiq just seconds after halftime.
"We got lucky with the posts," Madrid goalkeeper Thibaut Courtois said.
But Sociedad was undone when Gmez raised his arm above his head and blocked a shot by Arda Guler, allowing Vincius to go to the spot where he fired right past Remiro. Mbapp then beat Remiro when he shot one way as the goalie dove the other.
"We played a great game against the best team in the league and one of the best teams in the Champions League," Sociedad coach Imanol Agualcil said.
"We are angry at ourselves because we were better than they were today."
Sociedad has lost all three homes games this season.
Madrid forward Brahim Daz was substituted in the first half with a leg muscle issue.
Jesus Navas rifled in a powerful shot from a tight angle to give Sevilla its first victory of the campaign after edging Getafe 1-0 at home.
The 38-year-old wing back won the European Championship with Spain this summer, adding to his 2010 World Cup. Afterwards, he announced he was retiring from international soccer and he would likewise retire from club competition at the end of 2024.
His goal in the 23rd minute relieved some pressure on new coach Francisco Garca Pimienta.
Sevilla defender Marco was substituted in the first half after taking a hard knock to the head.
Javi Puado scored a hat trick to lead Espanyol to a 3-2 win at home over Alaves and secure a second consecutive win for the Barcelona-based club that spent last season in the second division.
Puado steered in a low cross to open the scoring in the 21st. He struck again with a glancing header to restore the host's lead in the 56th after Tomas Conechny equalized for Alaves.
The Espanyol forward took the winner from the spot after Nahuel Tenaglia pulled it even at 2-2. Puado converted the penalty earned after goalkeeper Antonio Sivera tripped Walid Cheddira in the area.
Also, Ayoze Prez scored late for Villarreal to win at Mallorca 2-1. That was his third goal in five games since Ayoze joined Villarreal from Real Betis in the summer.