Atletico Madrid were crowned LaLiga champions for the first time in seven years after holding off the title challenge of city rivals Real by coming from behind to beat Real Valladolid 2-1.
Second-half goals from Angel Correa and Luis Suarez overturned Oscar Plano's opener to secure silverware for Diego Simeone's side.
Victory for the visitors relegated Valladolid and proved vital as defending champions Real were denied successive titles by their city rivals.
Atletico, who finished two points clear of Zinedine Zidane's men at the summit, went into the weekend in pole position but faced a Valladolid side desperately seeking points in the scrap for survival.
Real Madrid were forced to settle for second in LaLiga despite coming from behind to beat Villarreal.
The defending champions had to win their final match of the season and hope for a slip at the last by Atletico, but their rivals' result meant what happened at the Estadio Alfredo Di Stefano was irrelevant in the context of the title race.
Victory for Los Blancos seemed unlikely for much of the contest, with Yeremi Pino giving the visitors the lead after 20 minutes, coolly flicking beyond Thibaut Courtois with the outside of his right boot, but Real did end their campaign with a flourish as Karim Benzema and Luka Modric struck late on for a 2-1 win.
Villarreal face Manchester United in the Europa League final on Wednesday and, had they held on against Real, they would have guaranteed a return to that competition next season, but their seventh-place finish means as things stand they will play in the Europa Conference League play-off round.
Bundesliga: Lewandowski breaks Muller's record
Bayern Munich striker Robert Lewandowski broke Gerd Muller's 49-year-old Bundesliga goal-scoring record for a season when he scored in the last minute of their last match of the season, a 5-2 win over Augsburg, taking his tally to 41 goals, one more than the former Bayern great.
The Poland striker is already second on the all-time scorers list in the Bundesliga, with 277 goals now, behind only Muller's 365. Muller set the previous record in the 1971/72 season with 40 goals, which Lewandowski equalled last week.
Lewandowski missed more than half a dozen clear scoring chances in the game and looked set to miss out on the record, with Augsburg determined not to let him add to his tally.
But the Pole was not to be denied and in the final minute, when Rafal Gikiewicz spilled a Leroy Sane shot, the forward rounded the 'keeper to score.
With coach Hansi Flick and several players of the old guard - Javi Martinez, David Alaba and Jerome Boateng - bidding farewell to the club, and 250 invited fans in the 75,000-seat arena, it was an emotional afternoon for Bayern with the Bundesliga long wrapped up.
It did not take long for the hosts to take the lead, with Augsburg's Jeffrey Gouweleeuw stabbing the ball into his own net from a Serge Gnabry cutback in the ninth minute.
Gnabry then headed in their second goal in the 23rd minute after Gikiewicz had saved a point-blank effort by Lewandowski.
A minute later Bayern 'keeper Manuel Neuer denied Daniel Caligiuri from the penalty spot, before Joshua Kimmich launched a 20-metre missile to make it 3-0 for the hosts.
Kingsley Coman also got onto the scoresheet, scoring two minutes before the break, with his low crisp shot whizzing past Gikiewicz.
The visitors came to life midway through the second half, scoring twice with Andre Hahn and Florian Niederlechner. But it was Lewandowski who had the last say.
At the other end of the table, former Bundesliga champions Werder Bremen were relegated for the first time since 1980 following their 4-2 defeat to Borussia Monchengladbach, along with already-relegated Schalke.
Cologne will go into the relegation play-offs after scoring an 86th-minute winner over Schalke.
Haaland double as Dortmund beat Leverkusen
Borussia Dortmund striker Erling Haaland scored twice as his team beat Bayer Leverkusen 3-1 to finish the season in third place.
The Norway international put the hosts in front only five minutes into the match, and bagged his 27th league goal six minutes from time.
After the early goal, Leverkusen managed to get back into the game but six minutes after the restart it was Dortmund captain Marco Reus' turn to score with a free-kick sailing in at the far post.
Lars Bender scored with an 89th-minute penalty for Leverkusen in the former Germany international's final game before retiring.
Elsewhere, second-place RB Leipzig ended the season with a 2-1 defeat at Union Berlin. Eintracht Frankfurt were 3-1 winners at home to Freiburg while Hoffenheim beat Hertha Berlin 2-1.
Armenia Bielefeld secured their Bundesliga status with a 2-0 win at Stuttgart while Mainz were 3-2 winners at Wolfsburg.