The Blaugrana were unable to add to their 3-1 Liga victory over the Andalusians at the weekend, and were handed a shock after 26 minutes when a defensive mistake gifted Manuel Iturra the opener.
However, Malaga did not hold onto the lead for long, and a pair of quickfire goals from Lionel Messi and Carles Puyol either side of the half-hour mark put Barca back in front.
Substitute Nacho Monreal was sent off with a quarter of an hour remaining, but on the brink of injury time, Ignacio Camacho struck to stun Camp Nou and leave the visitors with the advantage for the second leg at La Rosaleda in eight days.
Both managers opted to rotate their lineups, with 15 changes made from the 22 players that started the Liga clash on Sunday. Cristian Tello and Martin Montoya were among those given a chance to impress for Barca, while Malaga dropped Isco and Martin Demichelis to the bench.
The Blaugrana started brightly, and could have taken the lead as early as the sixth minute, but Sanchez fired over from yards out after some great build-up play from Messi and Tello.
Barca’s early dominance was such that it seemed only a matter of time before it made the breakthrough, but instead, a lapse at the back saw Malaga take the lead.
Thiago Alcantara was the culprit, as his hesitancy in possession on the edge of his own area allowed Iturra to rob the ball and slot into the bottom corner.
But the visitors’ lead would barely last three minutes, as Barca drew level thanks to a moment of brilliance from a familiar source. Messi showed great determination to win the ball off Weligton, and wasted little time in running through to bend home the equalizer.
And within seconds of the restart, the Catalans stormed ahead, when Thiago’s corner was headed home into the far corner with great purpose by Puyol.
It could have been 3-1 shortly before halftime, but Sanchez once again failed to find the target from a Tello center, this time spooning embarrassingly wide at the far post.
Barca continued to look the better side in the second half, and a stinging drive from Messi forced Carlos Kameni into an unorthodox save with his legs.
But the hosts were indebted to Pinto with just under 20 minutes remaining for a fantastic reflex save on Sebastian Fernandez's expertly struck volley.
And with a quarter of an hour to go, Malaga's task was made that much harder after substitute Monreal was given a straight red card for fouling Pedro as the last defender.
It seemed like game over for the visitors, but with one minute remaining in regulation time, Camacho popped up to convert a free kick at the far post to grab a second goal for the Andalusians, and send them into the return leg with the advantage on away goals.