Happened during 3rd battle of Panipat with Marathas too. Muslim chieftains like Najib Khan and Shuja Ud Dawlah, whose ancestors had migrated into India several generations ago (one would consider them "native"), joined Abdali, a foreign invader. Moreover, Shuja was a Shia and his father had been helped by Marathas, he didn't even have any regard for their favors.
The Maratha artillery was led by a patriotic Muslim Ibrahim Khan Gardi though. Exceptions are always there, India has produced many Muslim heroes and positive role models like Abdul Kalam, Salim Ali, Dara Sikoh, Ashfaqullah Khan, Makhdoom Moinuddin, Abdul Hamid, Hamid Dalwai. Quite a long list but you cannot ignore the fact that extra territorial loyalty is a part of Abrahamic doctrine. How many more lessons do we need ?
http://indiafacts.co.in/abrahamic-ideology-inspires-extraterritorial-loyalty/