The Sikh Confederacy Misls of the Punjab were consolidated into an Empire and expanded by Maharaja Ranjit Singh during the early years of the nineteenth century. During the same period, the British East India Company's territories had been expanded until they were adjacent to the Punjab. Ranjit Singh maintained an uneasy alliance with the East India Company, while increasing the military strength of the Sikh Khalsa Army, which also saw itself as the embodiment of the state and religion, to deter British aggression against his state and to expand Sikh territory to the north and north west, capturing territory from Afghanistan and Kashmir.