The 33-year-old centre-back lit up an otherwise lifeless encounter when he acrobatically connected with Giacomo Bonaventura’s corner on the edge of the box just after the hour mark, sending the ball flying into the top corner.
In hot and humid conditions in the Longgang Stadium in the southern Chinese city of Shenzhen, both teams were forced to make full use of substitutions and water breaks in what was a tight and disjointed game.
With Inter fielding a mostly second-string side, Milan enjoyed much of the early possession in the International Champions Cup opener, but French forward M’Byae Niang failed to convert their best first-half chance.
Despite making a raft of substitutions at half-time, Milan waited until an hour had gone before introducing their new Colombian striker Carlos Bacca, who was reportedly a Liverpool target before making the move to Italy from Sevilla.
But it was Mexes who turned out to be the unlikely match-winner just two minutes later.
The controversial France centre-back, who was awarded a one-year contract extension at the San Siro earlier this month despite a troubled season in Serie A, was given a playful kick up the backside from Milan’s new coach Sinisa Mihajlovic after breaking the deadlock in dramatic fashion.
As Inter pushed for an equaliser, the tensions and tempers typical of a Milan derby began to rise, with both sides committing a string of nasty and needless fouls.
With three minutes remaining, Milan midfielder and former West Ham loanee Antonio Nocerino was shown a straight red card for scything down Geoffrey Kondogbia, Inter’s new arrival from Monaco.
Hernanes had a chance to equalise for Inter in stoppage time, but the Brazilian midfielder fired wide.
Inter travel to Guangzhou to face Real Madrid on July 27 before Milan conclude the tournament against Real in Shanghai three days later.