Emperor Wudi (140-87 BCE) had the Great Wall extended northwestward all the way to the Gate of Jade (Yumen Pass), the westernmost garrison town near Dunhuang.
He then set up a system of garrisons all along this part of the Great Wall and put its headquarters in a town called Anxi (“Tranquil West”) and where the northern and southern Silk Routes historically diverged.
"[1] The name Guazhou (land/prefecture of melons) has a long contentious history; the name first appeared in records from the Warring States period, but Chinese historians have debated (since the 3rd century) whether it referred to a region in modern-day Gansu or Shaanxi.
From Northern Wei to Sui dynasty, Guazhou Prefecture contained both modern-day Dunhuang and Guazhou counties; in the Tang dynasty, the western region surrounding Dunhuang was renamed "Western Shazhou" while the region around Anxi was named Guazhou, with both falling under the administrative unit of "Shazhou".
The naming of these two regions (Shazhou and Guazhou) largely persisted till the Qing dynasty.