MADRID (AP) -- Real Madrid beat Barcelona for the second time in five days, a 2-1 win Saturday that will do little to prevent its rival from reclaiming the Spanish league title but could boost coach Jose Mourinho's team ahead of its Champions League match at Manchester United.
Sergio Ramos scored the tiebreaking goal on a header off Luka Modric's corner kick in the 82nd minute, and a contentious second half ended with Barcelona goalkeeper Victor Valdes receiving two yellow cards after the final whistle for arguing with the referee.
"We deserved to win. The team has been strengthened by these clasico matches," Ramos said. "We are going to Manchester convinced, but with respect for our opponent."
Karim Benzema put Real Madrid ahead in the sixth minute off a cross from 20-year-old Alvaro Morata, but Lionel Messi tied the score in the 18th following a pass from Daniel Alves, reaching 50 goals for the third straight season and extending his record La Liga scoring streak to 16 games. With his 18th goal in the clasico rivalry, Messi tied the record set by Real's Alfredo Di Stefano in the 1950s and `60s.
Ramos scored when he outjumped Gerard Pique for the header at the 6-yard box, helping Madrid to its first home league win over Barcelona since 2008.
During a chippy ending, Ronaldo hit a post with a free kick in the 88th minute, and referee Miguel Angel Perez Lasa didn't call a foul on Ramos' trip of Adriano in the penalty area during the third and final minute of stoppage time, prompting vehement arguments from Barcelona players.
Defending Spanish league champion Real Madrid (17-5-4) pulled within 13 points of first-place Barcelona (22-2-2) and within one point of second-place Atletico Madrid (18-5-2). Real won 3-1 at Barcelona on Tuesday to advance on 4-2 aggregate to the Copa del Rey final against Atletico.
After a 31-3-5 start in all competitions, Barcelona has lost three of its last four games, including a 2-0 defeat at AC Milan in the first leg of its Champions League round-of-16 matchup. Barcelona hosts the second leg of the total-goals series on March 12.
Barcelona's slide has coincided with the absence of first-year coach Tito Vilanova, who has been in New York for medical treatment since late January following an operation in Spain to remove a tumor from his saliva gland.
"It's impossible to keep up the same level of play for 12 months," Pique said. "But it is true that we have played three or four bad games, and that is serious because Barcelona always has to win. But this team will turn things around. I believe that because this is the best team I have ever played on. I'm surprised so many people have already jumped off the bandwagon."
Real Madrid started Cristiano Ronaldo on the bench and inserted the star forward in the 58th minute, wanting to keep him fresh for Tuesday's game at Manchester United. The teams tied 1-1 in Madrid in the first leg of their second-round matchup on Feb. 13.