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 were not ahead for long, and a pair of quickfire goals from Lionel Messi and Carles Puyol either side of the half hour mark put Barca in front.
Substitute Nacho Monreal was sent off with 15 minutes remaining, but late on, Ignacio Camacho struck to stun Camp Nou and leave the visitors with the advantage for the second leg at La Rosaleda in six days' time.
Both coaches opted to rotate their line-ups, 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 Alexis 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 they made the breakthrough, but instead, a lapse at the back saw Malaga, out of nowhere, 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 of Weligton, and wasted little time in running through to bend home the equaliser.
And within seconds of the restart, the Catalans stormed ahead, when Thiago’s corner was headed home with great purpose by Puyol.
It could have been 3-1 shortly before half-time, but Sanchez once again failed to find the target from a Tello centre, 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 their own shot-stopper, Jose 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 normal time, Camacho popped up to convert a corner at the far post to grab a second goal for the Andalusians, giving them two precious away goals to take back to La Rosaleda.