During the latter part of the 18th century, the monarchy slowly extricated itself from Belém-Ajuda. In 1794, a fire in Ajuda destroyed the Royal Tent ("Tenda Real"), forcing the royal family to abandon the location and take residence in the Queluz National Palace. A lack of funds had delayed completion of the Ajuda National Palace, so with the French invasion in 1807, the royal family fled to Rio de Janeiro. When they returned to Portugal in 1821, King John VI installed them in the Necessidades and Bemposta Palaces.