It was built during the Viceroyalty as a summer house for the highest colonial administrator, the viceroy. It was given various uses, from the gunpowder warehouse to the military academy in 1841. It became the official residence of Emperor Maximilian I and his consort Empress Carlota during the Second Mexican Empire (1864–67). In 1882, President Manuel González declared it the official residence of the President. With few exceptions, all succeeding presidents lived there until 1939, when President Lázaro Cárdenas turned it into a museum.