Sociedad succeeded where Borussia Dortmund had failed in Wednesday's 0-0 Champions League quarter-final first-leg draw as Malaga coach Manuel Pellegrini rested a host of key players ahead of Tuesday's return game in Germany.
Carlos Vela fired the Basques ahead in the 21st minute at their Anoeta stadium in San Sebastian, Alberto De La Bella added a second three minutes later and Antoine Griezmann made it 3-0 just after the half hour.
Pedro Morales pulled a goal back for the visitors just before the break and Inigo Martinez nodded a fourth six minutes into the second half.
Roque Santa Cruz made it 4-2 with another header 20 minutes from time but Sociedad comfortably resisted Malaga's comeback attempt to move on to 51 points with eight games left.
Malaga have 47 in fifth, the same as sixth-placed Real Betis after their 5-1 home win over Granada on Friday, and will be overtaken by Valencia if they win at home to Real Valladolid on Sunday.
Deportivo La Coruna’s hopes of beating the drop were raised with a 3-2 win over Real Zaragoza at the Riazor.
Three victories in a row have moved them from the foot of the table to 18th and within a point of their opponents.
Bruno Gama drilled a low shot to put the hosts in front, before Helder Postiga struck a penalty equaliser.
Zaragoza took a 35th-minute lead after a deft chip from Francisco Montanes, but Depor responded with a Carlos Marchena tap-in before the interval.
And the hosts grabbed the winner via an own goal from Abraham Minero, whose evening went from bad to worse when he was sent off late in the game for a second bookable offence.
- Sports & Recreation
- Carlos Vela