Nawab Ahmad Ali Khan of Malerkotla, 1920 (c).
The rulers of Maler Kotla (now in Punjab state of India) were descendants of a Pashtun saint belonging to Sarwani tribe who migrated to and settled in India during the times of Sultan Bahlul Lodi. In 1454 AD Shaikh Sadruddin received a gift of 68 villages near Ludhiana when he married the daughter of Sultan Bahlul Lodi. In 1458 a Bhatti Rajput chief of Kapurthala gave his daughter in marriage to Shaikh Saddrudin. His descendants from his Rajput wife became the rulers of Malerkotla while his descendants from his Pashtun wife (a Lodi princess) became caretakers of his tomb, khalifas. Shaikh Sadruddin founded a new town which was named as Maler. The fort and the surrounding houses were completed by the year 1461. Shaikh Saddrudin died in 1508 AD.
Mughal emperor Akbar removed all Pashtun jagirdars from Punjab who were linked to Lodi and Sur dynasties with exception of the descendants of Shaikh Sadruddin who were spared and allowed to retain their lands because of them being descendants of a Sufi saint. Bayazid Khan Sarwani (1593-1659) joined the Mughal military and eventually became a high ranking mansabdar. In 1656 AD Bayazid Khan founded Kotla, a walled town with seven gates just south of Maler.
In mid 18th century Jamal Khan, then Nawab of MalerKotla, became protégé of Ahmad Shah Durrani and supported him in his military campaigns in India. Ahmad Shah Durrani bestowed the title of Rustam-i-Hind on him. He was killed in a battle against Ala Singh (Sikh ruler of Patiala) in 1762. His son and successor Bhikan Khan continued supporting Ahmad Shah Durrani and received the right to mint his own coinage. He was shot in the back by a Sikh at Kotla in 1763/1764.
Malerkotla was attacked many times by Sikhs in 18th century but the principality managed to survive. In 1712 AD there were eleven parganahs in the state ruled by the Sarwani Nawabs, all of which, save Maler, succumbed to the rising Sikhs in the process of time. In 1794 , the Bedi Kala Dhari, a descendant of Guru Nanak, proclaimed a religious war against Afghans of Malerkotla for slaughtering cows and induced several Sikh chieftains to join him. Ataullah Khan, the Nawab of Malerkotla, managed to repel Bedi with assistance from the Sikh Maharaja of Patiala. After Ranjit Singh conquered Kasur (also ruled by descendants of Pashtuns) in 1808, he crossed Sutlej and attacked Malerkotla. Ataullah Khan saved his state by coming under the protection of British East India Company.