During the Han–Xiongnu War, Han general Huo Qubing expelled the Xiongnu from the Hexi Corridor and even drove them from Lop Nur when King Hunye surrendered to Huo Qubing in 121 BCE. The Han Empire acquired a new territory with trade access to the Western Regions, and also cutting the Xiongnu off from their Qiang allies. Again in 111 BCE, Han forces repelled a joint Xiongnu-Qiang invasion, and to consolidate the control of the region, four new commanderies were established in the Hexi Corridor, namely (from east to west) Wuwei, Zhangye, Jiuquan and Dunhuang, collectively known as the Four Commanderies of Hexi ().