Originally a Jesuit estate and convent dating from 1570, it became a residence of the Portuguese viceroys in Brazil at the end of the 18th century.
After the king's return to Portugal, the Prince Regent Pedro I continued to use the palace.
Upon his marriage to princess Leopoldina in 1818, they spent their honeymoon in the palace.
Emperor Pedro II later used the palace as a summer residence.
Following proclamation of a republic in 1889, the palace was converted to a military school.