After fighting Ahmad Shah Durrani in the later eighteenth century, the Sikhs took control of Punjab and managed to establish the Sikh Empire under Maharaja Ranjit Singh, which lasted from 1799 to 1849.