In 1854 president Antonio López de Santa Anna enlarged the area of Mexico City almost eightfold from the original , annexing the rural and mountainous areas to secure the strategic mountain passes to the south and southwest to protect the city in event of a foreign invasion. (The Mexican–American War had just been fought.) The last changes to the limits of Mexico City were made between 1898 and 1902, reducing the area to the current  by adjusting the southern border with the state of Morelos. By that time, the total number of municipalities within Mexico City was twenty-two.