Espanyol 1 Read Madrid 4: Ronaldo hat-trick in vain as Barca crowned champions
Real Madrid's La Liga title hopes were ended despite a 4-1 victory at Espanyol as Barcelona condemned them to second place with a win at Atletico Madrid.
A Cristiano Ronaldo hat-trick and one from Marcelo halted Real's run of three consecutive winless games in all competitions and spared the blushes of goalkeeper Keylor Navas, whose terrible error allowed Christian Stuani to equalise.
But Barcelona's 1-0 success at the Estadio Vicente Calderon in the penultimate game of the season saw them crowned champions and confirm Real as runners-up to complete a miserable week that also saw Carlo Ancelotti's side denied a place in the UEFA Champions League final by Juventus, increasing the pressure on the Italian coach.
Ancelotti made two changes from the side that drew 1-1 with Juventus in midweek, drafting in Navas for only his sixth Liga appearance of the season, with regular first choice Iker Casillas relegated to the bench.
Ancelotti also brought in Pepe for the injured Sergio Ramos in the Real back four.
Early chances were limited in a cagey opening spell and Ronaldo should have done better when a looping Daniel Carvajal cross set him up for a free header, but his effort hit the side netting.
On the occasions that the visiting front three did manage to carve out a chance, they found the Espanyol rearguard in good form, with Alvaro Gonzalez sliding in to deny Ronaldo as he skipped into the box, and Hector Moreno shackling Karim Benzema with a similarly clinical challenge moments later.
Espanyol striker Sergio Garcia felt he should have had a penalty when pushed inside the box from behind by Pepe, but his claims were waved away by referee Juan Martinez Munuera as a goalless first half left both sides somewhat frustrated.
Real finally broke the deadlock shortly before the hour mark after a sweeping move that began with Pepe threading a pass to Benzema, who found Ronaldo in plenty of space and the league's top scorer made no mistake, slotting his 43rd goal of the season low into the corner of the net.
Real's evening almost turned completely sour when a backpass from Pepe saw Navas take a touch that allowed Stuani to steal the ball from him and Sergio Garcia teed the Uruguayan up for an equaliser.
But Real were soon back in front through Marcelo's thunderous shot high into the net after a one-two with Ronaldo, who then made it 3-1 with a clinical finish after he was set up by substitute Javier Hernandez.
Ronaldo grabbed his seventh hat-trick of the season with a simple header at the far post in the final minute of the game, but it mattered little for Real.