Holders Barcelona set up a King's Cup semi-final against arch-rivals Real Madrid after battling to a thrilling 4-2 second leg win over a stubborn Malaga at the Rosaleda on Thursday.
Barcelona broke a rare two-game winless streak by outgunning Malaga to reach its sixth semifinal in seven years with a 6-4 victory on aggregate.
At 2-2, the game was heading for extra time when Andres Iniesta combined with Cesc Fabregas to score in the 76th minute. Messi then headed Barcelona's fourth and his 40th goal of the season just four minutes later.
"We knew it would be difficult coming in here in need of a win," said Barcelona defender Gerard Pique, who also scored for the visitors. "The result is fair, even though they played a great game. Now we have the luxury of playing a semifinal against Real Madrid."
The 2011 Cup winners Real Madrid host the first leg of the semi-final at the Bernabeu next week after Jose Mourinho's side beat Valencia 3-1 on aggregate, despite having two players sent off in Wednesday's 1-1 second-leg draw at the Mestalla.
Buy Real Madrid vs Barcelona Copa Del Rey Tickets online now!!
On the other side of the draw, Atletico Madrid set up a last four encounter with Sevilla after drawing 1-1 at their city rivals Real Betis to progress 3-1 on aggregate.
Sevilla, who beat Atletico 2-0 in the 2010 Cup final, swept aside Real Zaragoza 4-0 on aggregate in their quarter-final.
The semi-final first legs are scheduled for next week.
Thousands of tickets are on sale on Europe's biggest football ticketing website: 1st4 Football Tickets.com. We have UEFA Champions League tickets available such as Arsenal vs Bayern Munich tickets, Celtic vs Juventus tickets and tickets for AC Milan vs Barcelona. Last but not least, we also have Manchester United vs Real Madrid tickets available.