BARCELONA (Reuters) - Barcelona came through a testing local derby at Espanyol, winning 3-0 to cling to their slender lead at the top of La Liga after rivals Real Madrid had set the challenge by beating Valencia 2-1 in the earlier kick-off.

Barca triumphed thanks to two clinical finishes from Luis Suarez and a strike from Ivan Rakitic following a vintage slalom run by Lionel Messi.

Suarez pounced on a disastrous backpass from Jose Manuel Jurado to break the deadlock in the 50th minute and Rakitic sealed the win in the 76th by side-footing home Messi's cutback after the Argentine had torn through the home defence.

Suarez, who had failed to score in his previous five games in all competitions, took advantage of another calamitous error by the otherwise impressive Espanyol backline and rifled in Barca's third from close range in the 87th minute.

The pressure was on Barca after Real Madrid had beaten Valencia 2-1 earlier in the day to provisionally lead the standings, and the champions got an early fright when Jurado eased into their area but fired wide of the far post.

Espanyol's good organisation then went to waste when Jurado gifted the ball to Suarez, who knocked it past former Real Madrid goalkeeper Diego Lopez with an effortless flick of the outside of his right boot to send the champions on their way.

"I think we deserved the win because we gave a serious performance," said Barca coach Luis Enrique. "We knew that in the second half their high pressing would allow us to create more up front. We wore out the opposition."

Barca top the standings on 81 points due to their superior head-to-head record over Real, who also have 81 and have a game in hand.

Marcelo came to Real Madrid's rescue four minutes after his side had conceded a potentially crucial Valencia equaliser, from Dani Parejo, that could have seriously dented their hopes of landing a first title since 2012.

Cristiano Ronaldo scored his first goal in five league games to put Real ahead in the 27th minute but in the second half had a penalty saved by Diego Alves, who turned away a league-record sixth spot kick of the campaign.

Valencia had given Real a scare when Santi Mina hit the woodwork in the opening minute and the visitors pulled level in the 82nd minute with a thumping free kick from Parejo, the former Real academy player, who had fouled Luka Modric for the penalty.

Slideshow (5 Images)

Marcelo promptly grabbed the winner, cutting inside from the left-hand side of the area and curling the ball under Alves with his right foot, as Real's title bid benefited from yet another crucial late goal.

"I can't explain how we keep on scoring late goals. All I know is it's exciting, it's beautiful," coach Zinedine Zidane told reporters.

Atletico Madrid warmed up for their Champions League semi-final first leg against Real by hammering Las Palmas 5-0 away with two goals from Kevin Gameiro and strikes from Saul Niguez, Thomas Partey and Fernando Torres.

It was not all plain sailing for Diego Simeone's side, however, as they lost Jose Gimenez to injury, adding to the absences of fellow defenders Juanfran and Sime Vrsaljko for Tuesday's short trip to the Santiago Bernabeu.

Granada's run of six consecutive seasons in La Liga ended following a 2-1 defeat at Real Sociedad, leaving Tony Adams's side 10 points adrift of safety with three games left. They join basement club Osasuna in the Segunda Division next season.

Levante sealed their return to the top flight 11 months after being relegated by beating Real Oviedo 1-0 at home.