Disordered urban expansion has encroached on a large amount of ecological land, resulting in the steady degradation of urban ecology, which has an adverse effect on the sustainable development of the region. An ecological security pattern can effectively control urban expansion, and it is of great significance to balance urban development and ecological protection. In order to analyze the impact of ecological security patterns on urban expansion, Hangzhou was taken as an example, the CA-Markov model and FLUS model were used to simulate the urban expansion pattern in 2030 under the natural development scenario and the ecological security scenario. The results showed that (1) the ecological source area in the study area is 630.90 km2 and was mainly distributed in the western mountainous area. There are 14 ecological corridors, primarily composed of valleys and rivers. Ecological nodes are mainly distributed on the north and south sides of the main urban area. (2) From 2000 to 2018, the annual increase index (AI) of construction land decreased in the northeast and southeast directions but increased in the northwest and southwest directions, and in the northeast direction the value was always the highest. Except for the southwest direction, the average annual growth rate (AGR) of construction land in the other directions decreased. At a distance from the city center of 30 km, AI was relatively higher and was increasing, while AGR was declining. At a distance of 30–45 km, both AI and AGR were increasing, indicating that the focus of construction land was moving outwards. (3) From 2018 to 2030, under both natural development scenario and ecological security scenario, construction land would keep expanding, but the construction land area, proportion, AI, and AGR of the latter would both be smaller than the former, indicating that the ecological security pattern can effectively curb urban expansion. Because of a large amount area of ecological sources, the expansion of construction land in the southwest direction would be constrained, especially under the ecological security scenario. The methods and results of this study can provide theoretical and application references for urban planning and green development in metropolises.