Habitat quality has been widely used as an important indicator in the evaluation of regional ecological security and ecosystem services. Previous studies have focused on the influences of urbanization on habitat quality, but the protection measures about how to respond to the dynamic changes of habitat quality patterns are still unclear. This study investigated the habitat quality in the metropolitan region of China (Shanghai) by using InVEST model, and analyzed its dynamic changes from 2000 to 2017 for the sake of providing different protection objects and measures for Shanghai. The results showed that the habitat quality index (HQI) in 2017 was 0.42, and the accumulated area percentages of less than 0.4 in HQI reached 46%, whereas the habitat quality in Chongming district was the highest. The HQI and habitat protected index (HPI) showed an obvious decline tendency from suburban area to downtown area. The HQI in Shanghai gradually declined from 0.56 in 2000 to 0.42 in 2017, and the deterioration area in habitat quality nearly covered 33% between 2000 and 2017. Additionally, the area proportion of the median habitat quality (0.4 < HQI ≤ 0.6) drastically dropped, but the areas of the low (HQI ≤ 0.2) and the high (HQI > 0.8) in habitat simultaneously expanded. Therefore, the valuable habitat in the western and southern coastal wetlands, Dianshan lake and Chongming district in Shanghai should be strictly protected, which covered 30% of the metropolitan area in Shanghai, and about 17% of the region located in the inner coastal zones and northern of Chongming Island was in urgent need of habitat restoration. Our results provide vital references for the maintenance and sustainable management of urban habitats in the metropolitan region.