Water scarcity has become a serious problem in many parts of the world. While many previous studies have recognized that the changing water scarcity levels were attributed to population growth, economic development and climate change, effects of different factors on variations of water scarcity were rarely disentangled and quantified based on historical data. This study develops an analytical framework, based on the structural decomposition analysis, to decompose temporal water scarcity changes into effects of a number of hydro-climatic and socioeconomic factors. The methodology is applied to water scarcity analysis in Beijing, China, which has long been under severe water scarcity. Results from Beijing show that the population-driven water scarcity tends to increase, whereas the demand-driven water scarcity presents a slightly declining trend. The declining trend of demand-driven water scarcity is mainly attributed to industrial structure upgrade, improved water use efficiency, reclaimed and transferred water uses, and domestic water saving. In contrast, the economic development, population growth and increased ecological water use contribute to aggravating Beijing's water scarcity. High randomness in Beijing's water scarcity is mainly attributed to variability of available water resources. The results provide an in-depth understanding of dynamics in water demand and supply, and help develop policies towards sustainable water resources planning and management.