Sergio rose to head home from a corner in the 93rd minute to ensure a dramatic ending to a lively and entertaining game.
This fixture pitted the Primera Division's worst home team against the division's poorest away outfit.
Malaga had taken just 11 points at La Rosaleda all season, while Osasuna had failed to win away prior this match, picking up just two draws on the road this term.
And it was easy to see why as both defences looked unconvincing early on.
Quincy Owusu-Abeyie was allowed time and space by the visitors after four minutes, but sent a powerful shot wide of the target.
At the other end, Javad Nekounam saw a volley saved by Willy Caballero and the Iran midfielder headed inches wide midway through the half.
Malaga piled on the pressure in the second half and Sebas Fernandez was guilty of missing three glorious chances, twice shooting wide when he had looked certain to score and also directing a header off target from close range.
The finish was a frantic one, with chances for both sides to win it.
Fernando Soriano hit the post for Osasuna with four minutes left, and Weligton headed just wide at the other end moments later.
Following Sergio's goal, Malaga then almost levelled through Eliseu Pereira six minutes into added time.
But the game ended in a disappointing defeat for the Andalusians, who return to the bottom of the table with 11 games left.
Osasuna, meanwhile, are now three points clear of the drop zone.