Zhang He, left with no choice, followed orders and pursued to the Wooden Gate Path, where he encountered Zhuge Liang's ambush. A volley of arrows rained down; Zhang He was shot dead on the battlefield. Zhuge Liang safely returned to Hanzhong. Although this northern expedition did not achieve full success, it killed Wei general Zhang He, shaking the Central Plains.
It is said that after pacifying the Southern Barbarians, Shu Han's Chancellor Zhuge Liang rested his troops and again discussed a northern expedition. First, Cao Xiu was defeated by Lu Xun, and Cao Rui ordered Cao Zhen to replace him. Kongming anticipated that Cao Zhen was brave but lacked strategy, so he personally led the main army out of Qishan. Wei general Wang Shuang repeatedly challenged; Kongming set up an ambush and killed him, greatly dampening the Wei army's morale. Seeing Wang Shuang's defeat, Cao Zhen wanted to lead his own troops and advance separately. Kongming had long known his intention, so he set up an ambush at the mountain pass while ordering Wei Yan to feign defeat and lure the enemy. Cao Zhen, without suspicion, personally braved arrows and stones to pursue, but was surrounded by ambushing troops on all sides and suffered a great defeat. Kongming seized the victory and captured several cities in succession. Cao Zhen again led his army to face Kongming at Jigu; Kongming devised a plan, feigning defeat to lure the enemy deep, and used wooden oxen and gliding horses to transport grain, confusing the Wei army. Cao Zhen led his troops to raid the grain supplies but fell into Kongming's ambush, suffering heavy casualties and fleeing in disarray. Suffering repeated setbacks, Cao Zhen grew anxious and resentful. Seeing Cao Zhen's consecutive defeats, Cao Rui summoned Sima Yi to court for consultation. Sima Yi, always resourceful, knew that Kongming was an exceptional military commander, and proposed fortifying positions and clearing the fields, waiting for the Shu army to run out of provisions and retreat on its own. But Cao Zhen, unwilling to accept this, insisted on fighting again. Upon hearing this, Kongming rejoiced, saying, "Cao Zhen is without strategy — this is the perfect opportunity to crush him in one blow!" So he sent Zhao Yun and Wei Yan to split their forces and set up feigned formations. Cao Zhen, failing to see through this, launched a fierce assault with his main army; Kongming seized the moment to attack from both sides. Cao Zhen's army, demoralized and hit by fire attacks, was nearly completely annihilated. Cao Zhen fled in defeat, and accumulated worry turned into illness, from which he died without recovery. Wei ruler Cao Rui then ordered Sima Yi to take overall command of the troops in Yong and Liang provinces to resist the Shu army.