Late reign
Over the years, Wang Yan became accustomed to spend time in feasting, talking, and singing with Pan Zaiying, as well as the officials Han Zhao (韓昭) and Gu Zaixun (顧在珣). This allowed Song Guangsi to make the key decisions in Wang Yan's name. While there were officials who submitted petitions urging him to change his behavior, he did not do so (although he also did not, as Pan suggested, punish the officials). His cousin Wang Zongshou (王宗壽) the Prince of Jia also tried to get him to change his ways, to no avail.
In 923, Later Liang was destroyed by its archrival to the north, Later Tang. When Later Tang's Emperor Zhuangzong sent the news of Later Liang's destruction to Former Shu, the state was in much shock, but took no further action. When a comet (then considered a sign of impending disaster) subsequently appeared and the imperial astronomer indicated that a disaster was coming, Wang Yan established a field for offering prayer to the gods to try to stop the disaster. When the official Zhang Yun (張雲) argued that the more appropriate actions to take would be to make policy changes to appease the people, Wang Yan, in anger, exiled Zhang, and Zhang died on the way to exile.
Later Tang, while apparently in peace with Former Shu, was then planning an eventual invasion, which was also encouraged by the former Later Liang general Gao Jixing the military governor of Jingnan Circuit (荊南, headquartered in modern Jingzhou, Hubei), who had surrendered to Later Tang. In 924, Emperor Zhuangzong sent the emissary Li Yan (李嚴) to Former Shu, to observe the status of the Former Shu state. While at Former Shu, Li was making statements that glorified the Later Tang emperor that the Former Shu officials, including Wang Yan's adoptive brother Wang Zongchou (王宗儔), found offensive, and asked for Li to be arrested and executed, but Wang Yan did not agree. However, he commissioned Song Guangsi's brother Song Guangbao (宋光葆) (at Song Guangbao's request) as the military governor of Wude Circuit (武德, headquartered in modern Mianyang, Sichuan), to prepare the troops at Wude for a possible Later Tang evasion.
Li returned to Later Tang's capital Luoyang later in the year. Part of his mission was to exchange Later Tang horses for Former Shu jewels, but that part of the mission was unsuccessful, as Former Shu laws prohibited the shipping of jewels to Later Tang, except for lower quality jewels that were referred to as "items to send into the wild" (入草物, rucaowu). In displeasure, Emperor Zhuangzong stated, "How would Wang Yan know that he would not be a 'person to send into the wild'?" Li used this opportunity to further point out to Emperor Zhuangzong that Wang Yan was not personally handling the affairs of state and that Wang Zongbi and Song Guangsi, as well as other powerful officials, were corrupt, such that Former Shu should easily be conquerable.
Wang Yan was not completely oblivious to the possible Later Tang attack, as later in 924, he commissioned his adoptive brother Wang Zong'e (王宗鍔) as the commander at a task force, placed at Yang Prefecture (洋州, in modern Hanzhong, Shaanxi), and the general Lin Si'e (林思諤) to be the military governor of Zhaowu Circuit (昭武, headquartered in modern Guangyuan, Sichuan), to increase the preparedness. Meanwhile, Wang Zongchou, seeing that Wang Yan was not capable of ruling, discussed with Wang Zongbi the possibility of deposing Wang Yan, but Wang Zongbi hesitated. In anger and fear, Wang Zongchou died later in 924. Around this time, Wang Yan also alienated the general by putting the eunuch Wang Chengxiu (王承休) in command of the elite Longwu Army (龍武軍). Further, by the end of 924, believing that there would be peace between Former Shu and Later Tang (as the states have further sent emissaries to each other), Wang Yan began to cut back on some of the army deployments that he had ordered. In addition, at Wang Chengxiu's request, he commissioned Wang Chengxiu as the military governor of Tianxiong Circuit (天雄, headquartered in modern Tianshui, Gansu), sending the Longwu Army to serve as Wang Chengxiu's personal army. (Wang Chengxiu had gotten Wang Yan's agreement to this proposal by telling Wang Yan that Tianxiong's capital Qin Prefecture (秦州) was known for beautiful women and that he would collect them for the emperor.) He also made his uncle Xu Yanqiong (徐延瓊) the commander of the imperial guards, replacing Wang Zongbi, against the words left by Wang Jian.
By fall 925, Later Tang was deep in the preparation of an invasion of Former Shu, and Emperor Zhuangzong commissioned his son Li Jiji the Prince of Wei to serve as titular commander of the operations while making the major general Guo Chongtao Li Jiji's deputy, in actual command of the operations. Around the same time, Wang Yan, oblivious to the impending invasion, was still touring the realm with his mother and aunt, including to such places as Mount Qincheng, Peng Prefecture (彭州, in modern Chengdu), and Han Prefecture (in modern Deyang, Sichuan). Further, at Wang Chengxiu's urging, he made plans to visit Qin Prefecture, partly because he wanted to see Wang Chengxiu's wife Lady Yan, with whom he was having an affair. He paid no heed to advice to the contrary, including urging by Wang Zongbi and even Empress Dowager Xu not to undertake the trip. When he reached Han Prefecture, news came from the Wang Chengjie (王承捷) the military governor of Wuxing Circuit (武興, headquartered in modern Baoji, Shaanxi) that Later Tang had launched from an invasion, but Wang Yan believed this to be false report to dissuade him from the Qin trip, and therefore paid no heed. Only after, when he reached Li Prefecture (利州, Zhaowu's capital) and fleeing soldiers from Wuxing (where Wang Chengjie had surrendered by this point) arrived there as well did he believe that there was an actual Later Tang invasion. At Wang Zongbi's and Song Guangsi's advice, he stayed at Li and sent the generals Wang Zongxun (王宗勳), Wang Zongyan (王宗儼), and Wang Zongyu (王宗昱) to command the main Former Shu army to resist. However, they were crushed by the Later Tang forward commander Li Shaochen. Hearing of their defeat, in fear, Wang Yan fled back to Chengdu and put Wang Zongbi in charge at Li Prefecture; he also ordered Wang Zongbi to execute Wang Zongxun, Wang Zongyan, and Wang Zongyu. Meanwhile, other Former Shu generals surrendered or were defeated in droves by the Later Tang forces; this included Song Guangbao (who surrendered Wude Circuit) and Wang Chengxiu (who tried to launch his own forces to cut off the Later Tang army, but lost much of his troops as casualties against Qiang tribal forces, which stopped him from retreating), such that of his initial, 12,000-men army, only 2,000 survived.
Meanwhile, when Wang Zongxun, Wang Zongyan, and Wang Zongyu retreated to Li Prefecture, instead of executing them, Wang Zongbi showed them the order and planned with them to surrender to Later Tang together. Wang Zongbi marched his army back to Chengdu and seized the palace, putting the imperial household, including Wang Yan and Empress Dowager Xu, under effective house arrest, while seizing the imperial treasury. He sent letters to Li Jiji and Guo, offering to surrender, and also a letter in Wang Yan's name to Li Yan, offering to surrender as soon as Li Yan arrived. Li Yan thus went to Chengdu, where Wang Yan met Li Yan and entrusted his mother and wife to Li Yan. Wang Zongbi took the opportunity to also carry out a general purge of officials that he had long despised, while claiming that both he and Wang Yan had long wanted to submit but were stopped by these officials. When the main Later Tang forces under Li Jiji arrived at Chengdu, Wang Yan formally surrendered.