Manuel Iturra capitalised on sloppy Barca defending to give the visitors a surprise lead after 25 minutes at the Nou Camp, before two goals in as many minutes saw the holders swiftly forge ahead.
Messi, who picked up his fourth straight Ballon d'Or award earlier this month after netting a record 91 goals in 2012, equalised in the 28th minute thanks to an enterprising run down the right and a neat left-footed finish.
Captain Carles Puyol notched a second goal less than 90 seconds later, somehow twisting his neck enough to direct a looping header past Carlos Kameni.
However, Malaga refused to lie down and Ignacio Camacho's slick half-volley got them back on level terms a minute from time - despite having lost substitute Nacho Monreal to a 75th-minute red card for a shove in the back of Pedro Rodriguez.
Also on Wednesday, Real Zaragoza and Sevilla battled out a goalless draw at La Romareda to ensure there will be all to play for in next week's second leg at the Ramon Sanchez Pizjuan.
Real Madrid defeated Valencia 2-0 in the first leg of the first Copa quarter-final at the Bernabeu on Tuesday night, while Atletico Madrid and Real Betis kick off the fourth last-eight tie at the Vicente Calderon on Thursday.