Shah Jahan launched a prolonged campaign in the northwest frontier to recover Kandahar and other ancestral lands. The Mughal army lost more than five thousand lives during the successive invasions between 1639 and 1647. Then Shah Jahan realized the futility of his ambition and stopped fighting.
His Deccan policy was more successful.
He defeated the forces of Ahmadnagar and annexed it. Both Bijapur and Golkonda signed a treaty with the emperor. Shah Jahan carved four Mughal provinces in the Deccan - Khandesh, Berar, Telungana and Daulatabad. They were put under the control of his son Aurangazeb.
The last years of Shah Jahan's reign were clouded by a bitter war of succession among his four sons - Dara Shikoh (crown prince), Shuja (governor of Bengal), Aurangazeb (governor of Deccan) and Murad Baksh (governor of Malwa and Gujarat). Towards the end of 1657, Shah Jahan fell ill at Delhi for some time but later recovered. But the princes started fighting for the Mughal throne.
Aurangazeb emerged victorious in this struggle. He entered the Agra fort after defeating Dara. He forced Shah Jahan to surrender. Shah Jahan was confined to the female apartments in the Agra fort and strictly put under vigil. But he was not ill-treated. Shah Jahan lived for eight long years lovingly nursed by his daughter Jahanara. He died in 1666 and buried beside his wife's grave in the Taj Mahal.