The striker netted either side of Philippe Mexes' first of the season on a night that could have seen the end of Inzaghi's reign had the hosts failed to win.
All was not well for Milan, though, who played the game in front of a sparsely populated San Siro after the club's Ultras boycotted the match, displaying banners with the words "Game Over" and "Save Milan" in the Curva Sud.
Initially, Inzaghi's men struggled to find their rhythm, but Menez changed all that with a well-taken opener midway through the first half.
Diego Farias pulled Cagliari level early in the second period, only for Mexes to put Milan back in front two minutes later, much to the relief of Inzaghi.
Milan's much-needed victory was assured late on through Menez's controversial penalty, lifting the fallen giants into seventh place and dreaming of a European place.
Cagliari took advantage of Milan's nerves in the opening stages with a positive start and should have been ahead inside five minutes as Marco Sau fired wide from six yards after evading two challenges.
Despite a run of seven games without a win, the visitors continued to threaten, with Paul-Jose M'Poku twice denied by some last-ditch defending.
Having failed to make their early pressure pay, Cagliari were punished as Menez broke the deadlock with a stunning 21st-minute effort.
The French forward cut in from the left edge of the penalty area and curled his effort past Zeljko Brkic, before sending a message to those fans staying away from the game by cupping his hand to his ear in celebration.
Menez was Milan's shining light with threatening runs at the Cagliari defence, but it was Marco van Ginkel who went closest to doubling their advantage before the break with a long-range effort that was just over Brkic's crossbar.
Zdenek Zeman's side had lost much of their momentum prior to half-time, but improved after the restart and levelled immediately through Farias.
Sau began a swift break with a long ball for the Brazilian to chase, he bamboozled Mexes and calmly slotted past Diego Lopez.
Cagliari were not level for long, though, as Mexes made up for his calamitous defending minutes earlier with a well-executed volley from Menez's corner.
Such a frantic start to the second period meant Cagliari were never out of the game and, as the hour approached, Farias went agonisingly close to levelling for a second time with an effort that clipped the crossbar on its way over.
The woodwork saved Milan again to deny substitute Joao Pedro and three minutes later victory was assured as Menez took his tally to 15 goals for the season from a controversial penalty.
Substitute Alessio Cerci was fouled by Luca Ceppitelli on the edge of the penalty area, but referee Paolo Tagliavento stunned the visitors with the award of a spot-kick and Menez made no mistake.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.