In 439, aggravated that Juqu Mujian's sister and sister-in-law Lady Li (with whom Juqu Mujian was having an affair) had tried to poison Princess Wuwei, and also unhappy that Juqu Mujian had friendly relations with Rouran, decided to launch a major attack on Northern Liang. Li Shun, who had previously advised him to attack Northern Liang, by this point had somehow switched positions and, along with Tuxi Bi, opposed such military actions, stating falsely that there was so little water and grass for grazing in Northern Liang that Northern Wei troops would suffer from thirst and hunger. At Cui Hao's insistence, however, Emperor Taiwu believed that he could conquer Northern Liang, and he launched the campaign. He quickly reached the Northern Liang capital Guzang (姑臧, in modern Wuwei, Gansu) in the fall, capturing it after a short siege. Meanwhile, Yujiulü Wuti had launched a surprise attack on Pingcheng to try to save Northern Liang, but was repelled. (Cui Hao, who was a political enemy of Li Shun's, would attribute Li's switch in position to bribes by Juqu Mujian, and later Emperor Taiwu would force Li to commit suicide.) Northern Liang territory was largely in Northern Wei's control, and although both Juqu Mujian's brother Juqu Wuhui and Tufa Baozhou (禿髮保周), a son of Southern Liang's last prince Tufa Rutan, would try to hold various parts of Northern Liang territory, by 440 Tufa Baozhou would be dead by suicide after failures, and by 441 Juqu Wuhui had fled to Gaochang. Northern China was now united under Emperor Taiwu's reign, ending the Sixteen Kingdoms era and starting the Southern and Northern Dynasties era. He continued to treat Juqu Mujian as a brother-in-law, and Juqu Mujian was allowed to continue carry the title of Prince of Hexi.