While the Qin main force was fighting Xiang Yu in the Battle of Julu, Liu Bang advanced almost unresisted into the Guanzhong region, the Qin heartland. In 206 BCE, the last Qin emperor Ziying, after purging Zhao Gao, surrendered the capital Xianyang to Liu Bang, ending the Qin dynasty. Liu Bang acted very mercifully towards his conquered enemies and entered Xianyang peacefully, treated Ziying with dignity and forbade any of his men to harm or loot the locals. However, he was forced to hand over the city to Xiang Yu afterwards, and was coerced into giving up his claim over Guanzhong and accepting the enfeoffment of the remote Bashu region.