Former Manchester City striker Roque Santa Cruz headed in the only goal of the game in the 75th minute, shortly after coming on as a substitute.
Bernd Schuster's side moved five points clear of the bottom three as a result of the win, leapfrogging Celta Vigo in 14th.
Getafe remain in seventh but could find themselves further down the table by Sunday night, depending on the results of Valencia and Sevilla.
Malaga had picked up a positive result in their last league outing - a 1-1 draw at Villarreal - but the pressure was on Schuster after his side had thrown away a three-goal lead to draw 3-3 with Osasuna in a Copa del Rey tie the previous weekend.
Rafa Garcia squandered a free header early on for the visitors, and then Malaga defender Sergio Sanchez also failed to convert a header but forced Miguel Angel Moya to make a save. Vitorino Antunes sent a free-kick just wide of the near post, and then Juanmi hit the post as he tried to convert a cross from Antunes in the six-yard box.
Pedro Leon responded with a free-kick which forced Willy Caballero to dive low and pluck the ball away before it crept into the bottom corner. The goalkeeper had to make a similar save from Leon later in the half, and Antunes miscued from a strong shooting position just before half-time.
Malaga had fewer chances in the second half but still looked the most likely team to score. Juanmi was again presented with an opportunity to score, this time pouncing on a rebound but sending the ball over the bar.
With 15 minutes remaining, a goal finally arrived. Santa Cruz, who had come on to replace Pedro Morales only moments earlier, crept around the defence to head in a free-kick from Duda.
Although there was plenty of time for the visitors to react, Malaga were never in danger of letting go of their lead and hung on for their first win in four matches.