Zhuge Liang had attempted to invade the Wei territories via Mount Qi in his first expedition but to no avail; he then changed targets to Chenchang (陳倉; east of present-day Baoji, Shaanxi), a bridgehead fortress guarding the city of Chang'an.
Before Zhuge Liang marched towards Mount Qi, he sent emissaries to meet the Xianbei and Qiang peoples and incite them to create disturbances in Wei territory.
Zhuge Liang had sought aid from a Xianbei tribal chief, Kebineng, who went to Beidi Commandery (北地郡; around present-day central Shaanxi) to rally the locals to support the Shu forces.
[5] Sima Yi then ordered Dai Ling and Fei Yao to protect Shanggui County (上邽縣; in present-day Tianshui, Gansu) with 4,000 elite troops and set out with the rest of his men westward to relieve the mountainous battlefield.
"[10] Initially, the Wei emperor Cao Rui wanted to supply Sima Yi's army with the wheat in Shanggui County and had rejected a proposal to transport grain from Guanzhong to the frontline.
However, Zhuge Liang's movements turned out to be quicker than Cao Rui anticipated; only a portion of the wheat produced in Shanggui County was left after the Shu army's harvesting.
Using the river as a natural barrier, Zhuge Liang ordered his troops to position on the two hills on either side of Lucheng and pitch "covering camps" near the riverbank to take complete control of the water passage.
In May 231, Sima Yi sent an eager Zhang He to attack the Shu southern camp guarded by Wang Ping, while he personally led a frontal assault against Lucheng from the central avenue.
Li Yan, the Shu general responsible for overseeing the transportation of food supplies to the frontline, falsely claimed that the emperor Liu Shan had ordered a withdrawal.
Zhuge Liang abandoned Lucheng and retreated under the cover of night, but Sima Yi pursued him and inflicted roughly 10,000 casualties on the Shu army.
The Weilüe mentioned that Zhang He refused to obey Sima Yi's order and argued that, according to classical military doctrine, one should refrain from pursuing an enemy force retreating to its home territory.
At the same time, Li Yan sent Liu Shan a memorial which said that "the army feigned retreat in order to lure the enemy to do battle" in the hope that Zhuge Liang would resume the war so his failure to transport rations would go unnoticed.
However, Zhuge Liang decided to return to the Shu capital, Chengdu, and show Liu Shan the handwritten letters of Li Yan, so the latter could not deny the fault.