The wry joke "the operation was successful, but the patient died" might describe the liberation of Buda and Pest by the united Christian armies in 1686. The two towns were utterly destroyed, with only a few thousand people remaining alive inside the walls by the time the Turks were vanquished. Having survived the Turkish period intact, the royal palace was destroyed in the siege.
Resettlement and rebuilding were gradual, and formerly Gothic Buda took on a decidedly baroque appearance during the process. Though it would never again be a royal seat, the palace was rebuilt and expanded over the years.
Hungary was to be ruled by the victorious House of Habsburg until the collapse of the Habsburg empire in World War I. Relations with the new Viennese rulers were strained from the outset, flaring into open conflict for the first time when the Transylvanian prince Ferenc Rákóczi II led a series of valiant, but ultimately unsuccessful, rebellions between 1703 and 1711. The beginnings of modern Hungarian nationalism, which would explode into revolution in 1848, can be detected in this period.
Budapest's population grew steadily throughout the 18th century, while the university was moved from Nagyszombat (now Trnava, Slovakia) first to Buda, in 1777, and subsequently to Pest, in 1784. Pest expanded beyond its medieval city walls in the late 18th century with the development of Lipótváros (Leopold Town, now considered part of the Inner City).