BARCELONA, Spain - Barcelona held off a spirited Real Madrid fightback to hang on for a 2-2 draw on Wednesday that was enough to edge its eternal rival once again, this time for a place in the Copa del Rey semifinals.

Barcelona looked headed for a comfortable victory when it went up 2-0 by halftime in the second leg of another feisty "clasico" matchup, but ended up narrowly escaping with a 4-3 aggregate victory after Madrid rallied in the second half.

Defending champion Madrid dominated much of the frantic, up-tempo game full of penalty appeals and physical play, but still had to watch as Barcelona took a commanding lead into halftime thanks to late first-half goals from substitute Pedro Rodriguez and Daniel Alves.

Having lost the first leg 2-1 at home and needing three goals to advance, Cristiano Ronaldo started the comeback with a 68th-minute goal before substitute Karim Benzema equalized from an individual effort in the 73rd.

But Madrid finished the game with 10 men after Sergio Ramos was sent off for a second booking the 88th, and Barcelona once again came out on top of the traditional matchup as Madrid coach Jose Mourinho left the Camp Nou winless in nine visits. It was a measure of revenge for last year's loss to Madrid in the cup final, although the scrappy match cost Barcelona Andres Iniesta and Alexis Sanchez to injury.

"We played a great team, this is a 'clasico' so you know right up to the end you're going to have to suffer and hold off your rival," said Alves, who scored one of the best goals of his career with a scorching shot to close the first half. "They caused us a lot of problems by pressuring high, but we knew how to respond."

Mourinho certainly didn't approach the return with the same defensive plan he used in the first leg, and opted to include Pepe in the lineup despite the defender — who was jeered loudly with every touch — drawing widespread criticism for stamping on Lionel Messi's hand in the first leg. Mourinho's future with the Spanish club had been questioned following the lacklustre first leg loss.

"We played a good game, the players played a very good game," said Mourinho, who did not apologize for his first-leg tactics. "We came here looking to win. We knew we were behind, we were motivated, wanted to win."

Madrid was unlucky over the first half hour as Mesut Oezil hit the crossbar with a superb 30-meter effort, and Barcelona keeper Jose Manuel Pinto made a number of point-blank stops on Gonzalo Higuain.

Iniesta was taken off with a leg injury and replaced by Pedro after 30 minutes. Pedro ran wide on a counterattack as Messi drew three defenders before flicking a perfect pass over to the Spain international, who slotted past Iker Casillas for the 43rd-minute opener with Barcelona's first shot on goal.

Lassana Diarra escaped a second booking for tackling Messi's just before the break, but Barcelona scored from Xavi Hernandez's resulting free kick.

Xavi, celebrating his 32nd birthday, had his shot deflected into the path of Alves, who rifled an unstoppable first-time shot from just outside the area into the top far corner past the outstretched Casillas.

That left Madrid's players looking dejected as they went into halftime staring at another loss to Barcelona — with some apparently doubting whether it was even possible to beat the Catalan club.

"I heard that in my dressing room," said Mourinho, whose team has only won once in the last 14 games against Barcelona with the Portuguese coach again putting some blame on the referee. "But I didn't say that."

Mourinho took off Diarra, Kaka and Higuain in the second half for Esteban Granero, Jose Callejon and Benzema and the visitors attack prospered.

Ramos had a goal disallowed in the 54th for a foul, before Ronaldo managed to breathe life into the already highly charged match by running onto Oezil's through ball to round Pinto and score from a tight angle.

Benzema then juggled a loose ball over Carles Puyol inside the area and controlled it with his hip before volleying in the equalizer to put Madrid one goal away from advancing.

Both teams had a number of penalty appeals turned down throughout the match and Madrid could not find a winner as Barcelona continued its recent domination over its top rival.

"We were superior to Barca's team today," said Pepe.

Barcelona coach Pep Guardiola said Madrid was able to disrupt Barcelona's normally fluid play with its physical play.

"When you go up against such a good team, these things happen," Guardiola said. "You have to get over these things and we did."

The Spanish and European champions will play either Valencia or Levante in the semifinals, with Valencia ahead 4-1 going into Thursday's return match.

Earlier Wednesday, Athletic Bilbao beat Mallorca 1-0 to reach the semifinals 3-0 on aggregate, where third-tier club Mirandes awaits.