For several years, Real Betis delivered an attractive, attack-first style of soccer that succeeded in pulling off the occasional big win but also left its defense exposed to some humbling losses.

Manuel Pellegrini has changed that since taking over at the start of last season. The former Manchester City and Real Madrid coach has forged Betis into a complete team this campaign, one that can score in bunches while protecting its area.

The result has put the Seville-based club in a tight fight for a top-four finish in the Spanish league — and the prize of a Champions League berth.

The attacking prowess of Betis will be up against Atlético Madrid on Sunday, a tough test for the surprisingly shaky defense of Diego Simeone’s team.

Betis enters the weekend in third place, but with Atlético and Barcelona only one point behind. Real Sociedad trails Betis by two points and Villarreal is also in striking distance, four points adrift.

Only two of that pack will join Madrid and Sevilla, the only teams left with realistic chances to win the league title, in Europe’s top club competition next season.

With a deep squad featuring the passing and leadership of midfield pair Sergio Canales and Nabil Fekir, Betis has the second-best attack in the Spanish league. Its 48 goals are only behind Madrid’s 52. Striker Juanmi Jiménez is having his best season with a team-high 16 goals in all competitions. Borja Iglesias has scored 13 times, with Willian José chipping in with 10 more goals.

Atlético, meanwhile, has allowed more goals (34) than 10 other league teams, something unthinkable for Simeone, who over his decade in charge has made a strong defense the foundation of winning titles.

Atlético has improved of late. On either side of its 1-1 draw with Manchester United in the Champions League, it has kept clean sheets in consecutive league victories over Osasuna and Celta Vigo by a combined score of 5-0.

The visitors to the Benito Villamarín Stadium will also have the advantage of having had five more days of rest than Betis before the game.

Sevilla will try to keep the pressure on Madrid when it plays at struggling Alavés on Friday. A win will leave it three points behind the leaders.

Madrid hosts Sociedad on Saturday, three days before it welcomes Paris Saint-Germain in the Champions League. A late goal by Kylian Mbappé gave PSG a 1-0 victory in the first leg.

Barcelona visits Elche on Sunday on its best run of an otherwise poor season. It has scored four goals in three consecutive wins over Valencia, Napoli and Athletic Bilbao. New signing Pierre-Emerick Aubameyang has scored five times in those wins.

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