Ten-man Malaga have fought back from 2-1 down to ensure that they head into the second leg of their Copa del Rey quarter-final against Barcelona level.
It looked like it would be a comfortable night for the cup holders as they dominated possession in the early stages of the game.
Lionel Messi looked threatening throughout the match, having his first attempt on goal after 20 minutes, firing the ball just over the crossbar.
However, it was the visitors who broke the deadlock in the 25th minute through Manuel Iturra after the Chilean stripped the ball from Thiago.
Malaga's lead was short-lived, as Messi beat two defenders before curling the ball into the net.
Carles Puyol put Barca in front less than two minutes later, connecting with a Thiago corner and heading the ball in.
The opening 15 minutes of the second half were less intense, before Messi looked for his second with a strike from inside the penalty area and forced a save from Carlos Kameni.
Malaga had a chance to level the scores in the 72nd minute, with Sebastian Fernandez forcing a save from Jose Manuel Pinto.
The visitors played the final 13 minutes with only 10 men on the field after Nacho Monreal was shown a red card for bringing down Pedro, having been the last man.
Despite their numerical disadvantage, Malaga forced an equaliser in the final minute before stoppage time, Duda finding Ignacio Camacho for a header.
The second leg of the quarter-final tie takes place next Wednesday.