Shivaji left behind a state always at odds with the Mughals. Soon after his death, in 1681, Aurangzeb launched an offensive in the South to capture territories held by the Marathas, the Bijapur based Adilshahi and Qutb Shahi of Golkonda respectively. He was successful in obliterating the Sultanates but could not subdue the Marathas after spending 27 years in the Deccan.The period saw the capture, torture, and execution of Sambhaji in 1689, and the Marathas offering strong resistance under the leadership of Sambhaji's successor, Rajaram and then Rajaram's widow Tarabai. Territories changed hands repeatedly between the Mughals and the Marathas; the conflict ended in defeat for the Mughals in 1707.