To teach them a lesson, the Han court sent an army led by General Li Guangli to subdue Dayuan, but their first incursion was poorly organized and undersupplied.
[1] For decades prior the Han followed a policy of heqin (和亲) sending tribute and princesses to marry the Xiongnu shanyu to maintain peace.
[4] The Records of the Grand Historian and the Book of Han describe the Dayuan as numbering several hundred thousand people living in 70 walled cities of varying size.
However unlike the other envoys, the ones from Dayuan did not conform to the proper Han rituals and behaved with great arrogance and self-assurance, believing they were too far away to be in any danger of invasion.
Enraged by this act of contempt, the nobles of Dayuan ordered Yucheng (modern Uzgen), which lay on their eastern borders, to attack and kill the envoys and seize their goods.
While crossing the Tarim Basin and the Taklamakan Desert (of modern Xinjiang), Li's army was forced to attack the nearby oasis states because they refused to provide them with supplies, but were sometimes unable to overcome them.
After suffering a defeat at Yucheng, Li concluded that their current strength would not be sufficient to take the Dayuan capital, Ershi (Khujand), and therefore retreated to Dunhuang.
In the autumn of 102 BC, Li set out with an army of 60,000 penal recruits, (collectively called 惡少年, literally meaning "bad boys") and 30,000 horses along with a large number of supply animals including 100,000 oxen and 20,000 donkeys and camels.
[10][11] Facing a determined Han expedition army, most of the Tarim Basin oasis-states simply surrendered without a fight upon seeing the overwhelming display of power.
Despite meeting no major setbacks and bypassing Yucheng entirely, Li still lost half his army to the harsh terrain and desertion by the time they reached Dayuan.
A force of Wusun cavalry 2,000 strong was also present at the request of Emperor Wu, but they refused to take part in the siege out of fear of offending either parties.
[12] Dayuan's cavalry forces sallied out for a pitched battle in an attempt to break the siege, but they were easily defeated by the Han crossbowmen.
Han engineers set to work on the river passing through Ershi and diverted it, leaving the city with no source of water as they had no wells.
Before departing, Li enthroned one of the nobles called Meicai (昧蔡) as king, since he had previously shown kindness to the Han envoys.
Having heard of Dayuan's defeat, the rulers of the Tocharian oasis states sent their kin along with the army back to the Han capital, where they presented tribute to Emperor Wu.
Despite the overall success of the second expedition, having adequate supplies and losing only a small portion of the army in battle, the entire campaign was marred by corruption and self interest.
Li's soldiers, being taken from the prison population and undesirable class, were given very little care by their generals and officers, who instead abused them by withholding rations, causing desertion.
[12] More than a year later, the nobles of Dayuan banded together and killed King Meicai, whom they considered responsible for the entire affair with the Han in the first place.