Gareth Bale had countless chances to score for Real Madrid, but it wasn't until the dying minutes with stoppage time looming that the Welshman struck.
More from our team sites
After a typically tight and physical start to the Clásico, it was Real Madrid who would take an early lead, slicing apart Barca's defense on the counter attack.
Karim Benzema picked out Ángel di María making a run through the midfield, into the acres of empty space left by Barca's high defensive line. Despite having Gareth Bale out to his right, Di María kept the ball, used a clever stutter step to create some space between himself and Jordi Alba, and then placed a shot past José Manuel Pinto that the keeper really should have done better with.
With a goal secured, it was time to add a bit of nastiness to the match.
In the 17th minute, both Pepe and Neymar were booked for a bit of handbags on the edge of the Madrid 18-yard-box. Neymar wasn't pleased with Fabio Coentrão's tackle, and nudged the defender with his head. Pepe immediately decided to get involved, grabbing Neymar. The two exchanged pleasantries and after a prolonged discussion with the referee, both were given yellow cards.
Bale missed two good chances to double Madrid's lead in the opening ten minutes of the second half. First, he misfired on a tough angle shot on the break, sending the ball wide of the far post. Then in the 54th minute, a half-volley attempt just outside the Barca box sailed every so slightly over the crossbar.
The Welsh winger completed the hat trick of disappointment in the 67th minute when he headed the ball past Pinto from short-range. As the celebrations began, the referee disallowed the goal, calling a foul on Bale.
Less than two minutes later, Barca awoke and scored the equalizer in the most un-Barcelona way ever...a header off a corner kick. A rare long corner kick from Xavi found Marc Bartra who watched as Pepe misjudged the ball, before heading the ball past a diving Iker Casillas to make it 1-1. It's Bartra's first career goal against Madrid in his first ever appearance in a Clásico.
That goal was also the first allowed in the Copa del Rey by Casillas since Dani Alves beat him back in 2012, a streak of over 1,000 minutes without conceding.
After all the misses and close calls, it was inevitable that Garth Bale would score the winning goal for Madrid. Bale avoided Bartra's attempt to muscle him off the ball as he raced down the left wing, before turning inside and placing the ball between Pinto and the near post, giving Los Blancos a 2-1 lead with just five minutes to play.
Neymar had a chance to pull Barca back even in the 89th minute, but his shot hammered off the post and right back to Casillas, who was happy to cover it up.
The victory gives Madrid their 19th Copa del Rey trophy, third all-time behind Barcelona and Athletic Bilbao.
Real Madrid: Casillas, Carvajal, Pepe, Ramos, Coentrão, Alonso, Modric, Isco (Casemiro 89'), Di María (Illaramendi 86'), Bale, Benzema (Varane 90')
Goals: Di María (10')
Barcelona: Pinto, Alves, Mascherano, Bartra (Sánchez 86'), Alba (Adriano 46'), Busquets, Xavi, Iniesta, Neymar, Fàbregas (Pedro 60'), Messi
Goals: Bartra (68'), Bale (85')