In ancient times, Yu the Great bored a tunnel in the nearby Mount Longmen (Dragon Gate Mountain) to alleviate the frequent flooding that occurred in the area, which led to the area being called Dragon Gate (). During the Western Zhou Dynasty, the area was bestowed on the Han Marquises. During the Spring and Autumn period, the area was under the administration of the State of Jin and became known as Hanyuan () or Land of the Hans. In the Warring States period, the area belonged to the State of Wei and was called Shaoliang (). Towards the end of the Warring States Period, the State of Qin conquered and designated the area as Xiayang County (). In the Sui Dynasty, the area received its present name of Hancheng.