Climate change, combined with rapid urbanization, can face many challenges in achieving urban ecological sustainability, especially in developing countries. Due to the lack of valuable data, measuring the negative impact of this urban environmental damage, particularly in African cities, is however difficult to investigate. In this context, this research proposes an efficient index, including environmental, societal, and topographic indicators, extracted from remote sensing data, to evaluate the spatial ecological vulnerability of Tangier city in Morocco. This composite index, called the Urban Ecological Quality Index (UEQI), was developed for 2002, 2013, and 2023 in the spring season, using the Principal Component Analysis (PCA) as a multivariate statistical technique. Furthermore, the spatial autocorrelation analysis of the UEQI was performed to study the correlation between the index values and its surroundings, using Global Moran's I and Local Moran's I test statistics. The results show that on the one hand, zones located in the center of the city kept poor ecological quality in the three studied years, where the lack of green spaces and the high population density are the main reasons for this bad state. On the other hand, climate variability, such as precipitation change, directly affects the ecological quality of Tangier city. In fact, from 2002 to 2013, due to Morocco's increased precipitation during this decade, the UEQI improved in 36%, unchanged in 50%, and degraded in 14% of the study area. However, from 2013 to 2023, with more than 52% degraded UEQI, the ecological quality of the city was affected by drought periods, which have been more frequent and intense in this decade, especially in green areas and agricultural land.