BARCELONA, Spain -- Diego Costa sparked Atletico Madrid's exhilarating 2-1 comeback at Athletic Bilbao on Saturday, while Lionel Messi converted a late penalty to keep Barcelona one point behind the Spanish league leaders with a contentious 1-0 win at Espanyol.
Cristiano Ronaldo scored as well before Gareth Bale netted a brace as Real Madrid routed Rayo Vallecano 5-0 at home, breaking a rare two-game losing streak and keeping their team within three points of the pacesetters.
A tireless Diego Costa cancelled out Iker Muniain's opener before Koke "Jorge" Resurreccion followed with a 55th-minute header to keep Atletico on course in its search for its first league title since 1996.
Messi made sure Barcelona stayed right behind Atletico with seven games left by slotting in a spot kick in the 77th when Espanyol defender Javi Lopez handled in the area.
Ronaldo leads the league with 28 goals through 31 games. Diego Costa is next with 25, trailed by Messi with 23.
Barcelona hosts Atletico on Tuesday in the Champions League quarterfinals, a preview of their meeting in the last round of the Spanish league season.
Diego Costa was a nightmare for Bilbao's defence, and could have had at least one more goal given the number of opportunities he fought hard to create. He did help leave Bilbao with 10 men by earning a second yellow card for Aymeric Laporte in the 86th.
"Diego Costa is huge for us," said Koke. "We have seen that from the start of the season and I only hope he keeps it up. We knew that we were visiting a tough ground and the game was like we expected. Diego (Costa) had space to roam and we found him. Then we turned it around."
Muniain took advantage of a rare defensive lapse by Atletico to hit six minutes in when he chased down a pass touched on by Aritz Aduriz and used one touch to lob the ball over onrushing goalkeeper Thibaut Courtois.
Atletico's answer came in the 22nd when Koke intercepted Ander Iturraspe's ill-advised pass and left Diego Costa alone to beat goalkeeper Gorka Iraizoz.
After Diego Costa almost struck again seconds after the restart, Koke played Filipe Luis wide and ran forward to nod his returned cross into the net to momentarily silence the raucous San Mames crowd.
Diego Simeone's side still needed Courtois' one-handed stretch to swat away Aduriz's header with 10 minutes to play.
Simeone called his team's game the "best of the season."
"We are aware of the great match we played," said Simone. "We went straight at recovering the ball and exploiting the space up front for Diego (Costa). We didn't waste time despite falling behind. We always knew how we wanted to play."
Bilbao was left in fourth place and in control of the last Champions League spot with a six-point advantage over Sevilla after it lost 1-0 at Celta Vigo from Manuel "Nolito" Agudo's 87th-minute penalty.
Espanyol's physical style kept Messi and the crosstown visitors in check until Lopez was whistled, allowing Messi to score the spot kick for his eighth goal in his last four games and save Barcelona from a costly draw.
Barcelona was fortunate, however, that the referee did not see the ball hit Lopez after Dani Alves' cross first ricocheted off Neymar's arm, as television replays appeared to show.
"Derbies are always tough, and this was a tense game with lots of interruptions, fouls and controversy," Barcelona midfielder Sergio Busquets said. "Three weeks ago we were in a difficult situation. Now we are in a privileged one and control our fate. I hope it stays like that until the last game against Atletico."
Espanyol played the last seven minutes and injury time with 10 men after goalkeeper Kiko Casilla used his hands outside the box. Lopez had to take over goalkeeping duties with Espanyol's three substitutes already made and played admirably, making two saves.
Ronaldo and Bale were the main attractions in an otherwise dreary, rainy, and lopsided match at the Santiago Bernabeu.
Ronaldo opened from Bale's pass in the 15th before setting up Dani Carvajal in the 55th. Bale scored twice on the break in the 68th and 70th. Substitute Alvaro Morata curled in Madrid's fifth in the 78th.