The rule of the Gaekwads began when the Maratha general Pilaji Rao Gaekwad conquered the city of Baroda from the Mughals in 1721. The Gaekwads were granted the city as a fief by the Peshwa of the Maratha Empire. When the Maratha Empire was defeated by the Afghans in the Third Battle of Panipat in 1761 the Gaekwads and several other powerful Maratha clans established themselves as independent rulers of the region. However they respected the nominal authority of the Peshawas and the suzerainty of the Bhonsle Maharaja of Satara.
The Gaekwads together with other Maratha rulers fought the First Anglo Maratha war against the Britishers. In 1802, with the British interference a Gaekwad Maharaja inherited the throne against his rivals and this helped in developing a healthy relation between the two. The Gaekwad concluded a treaty with the British that recognized the independence of the Maratha Empire and gave the Maharajas local autonomy against the recognition of British suzerainty. After India gained independence, the last ruling Maharaja of Baroda acceded to India. Baroda was eventually merged with the Bombay and later taken in Gujarat in 1960 when the states were reorganized on the basis of language.