The grain officer Li Yan, due to slow transport of provisions, falsely reported that the grain was exhausted, intending to force Zhuge Liang to withdraw. Zhuge Liang, knowing it was a deception, had no choice but to order a retreat to avoid demoralizing the army. After returning to Hanzhong, he investigated and confirmed Li Yan's false report of military intelligence, deposing him to commoner status. Although this northern expedition captured two commanderies, it failed to achieve complete success due to issues with provisions. Zhuge Liang, unwilling to give up, reorganized the army to plan further advances.
Soon after, learning that Hao Zhao was holding Chencang securely, Zhuge Liang led a large army out of Qishan again. The Wei general Wang Shuang came to challenge and was beheaded by Zhuge Liang. Unable to capture Chencang after several attacks, Zhuge Liang withdrew and camped at Lucheng upon hearing that Sima Yi was approaching to reinforce. Sima Yi pursued but was again defeated by an ambush. The armies of Wei and Shu confronted each other, with both sides experiencing victories and defeats.
Seeing that Sima Yi remained on the defensive, Zhuge Liang implemented a stratagem of sowing discord, sending out men to spread rumors that Sima Yi was secretly communicating with Shu. Cao Rui became suspicious, recalled Sima Yi, and replaced him with Cao Zhen to command against Shu. Cao Zhen underestimated the enemy and attempted to divide his forces for a deep strike, but fell into Zhuge Liang's ambush. He was heavily defeated and died of grief and anger. Left with no choice, Cao Rui had to reactivate Sima Yi as Grand Commander to resist Zhuge Liang. Sima Yi regained command of the military and confronted Zhuge Liang at Qishan. Zhuge Liang lured the Wei generals Fei Yao and Dai Ling deep into Shu territory and captured them alive. He also set an ambush at Jigu Valley, trapping the Wei general Zhang He.
Zhang He failed in repeated attempts to break out, and the Wei army fell into difficulty. However, the Shu army's supply routes were long, and combined with continuous rainy weather, provisions became insufficient. Zhuge Liang had no choice but to order a retreat back to Hanzhong. When Sima Yi learned of Zhuge Liang's withdrawal, he wanted to pursue. Zhang He advised: 'An army in retreat should not be obstructed, and a desperate enemy should not be pursued.' The Chancellor's retreat must be a ruse.' Sima Yi refused to listen and strongly ordered Zhang He to lead troops in pursuit.