The Nigerian scored twice after East Bengal went ahead against the run of play in the 29th minute, when Alvito D'Cunha did well to finish off a move he had initiated with Baichung Bhutia.
Ali restored parity in the 33rd minute, darting in to head home a floater from Steven Dias following a corner, and then put Mahindra ahead in the 42nd minute in similar fashion, heading a Mohd Rafi cross from the left.
Yusif Yakubu put East Bengal on level terms in the 62nd minute, but N K Pradeep's 30-yard shot from a defensive clearance got the Mumbai side the match-winner in the 75th minute.
Despite a soggy playing surface, both teams produced entertaining fare.
If Mahindra held a slight edge in the first half, which ended 2-1 in their favour, it was the introduction of Yakubu in the second session that gave the Kolkata giants slight ascendancy, which, unfortunately, they could not convert into goals.
They could have gone home with a point, but Mahindra goalkeeper Subashish Choudhary denied them, collecting a header from Bhutia in the 83rd minute.
Following the victory, Mahindra have four points from two matches, having drawn 1-1 with defending champions Churchill Brothers in their opening match, while East Bengal suffered their first defeat after a goalless draw with Pune FC.
Photograph: Satish Bodas
Mahindra United signs Serb Mijin
Chirag hand Mahindra second defeat
Mohun Bagan hold Mahindra, enter semis
Spotted: Baichung Bhutia in Bangalore
East Bengal player beats up team-mate