In spring 618, after another major rebel leader, Li Mi the Duke of Wei, achieved a great victory over the Sui general Wang Shichong and approached the Sui eastern capital Luoyang, Xu Yuanlang, along with several other key rebel leaders, nominally submitted to him and requested that he take imperial title, but Li declined. After Wang defeated Li in 619, Xu submitted to the Sui emperor Yang Tong, then at Luoyang, although he also offered submission to Emperor Gaozu of Tang and was created the Duke of Lu. After Wang had Yang Tong yield the throne to him later that year, ending Sui and establishing a new state of Zheng, Xu also nominally submitted to Zheng. In winter 619, after another rebel leader, Dou Jiande the Prince of Xia, conquered the Tang territory north of the Yellow River, Xu submitted to Xia. In 621, when Zheng was under attack by the Tang general , Dou requisitioned troops from Xu to aid Wang. Later that year, Dou was defeated and captured by Li Shimin, and Wang also surrendered to Li Shimin. Xu then submitted to Tang as well and was made the commandant of Yan Prefecture and again created the Duke of Lu.
Resistance against Tang and death
Later in 621, Dou's general Liu Heita, supported by a group of Dou Jiande's supporters angry that Tang had executed Dou Jiande , rose against Tang rule, and quickly captured most of Dou's former territory. In doing so, he was in communication with Xu, and Xu also rose, capturing the Tang general Sheng Yanshi and receiving support from eight prefectures. He ordered Sheng to write a letter to Sheng's brother, who was the county magistrate of Yucheng , to get Sheng's brother to surrender, but Sheng instead wrote a letter that told his brother to be faithful and not betray Tang. Xu, after seeing the letter, laughed and said, "General Sheng has integrity and honor, and I shall not kill him." Liu gave Xu a general title, and in winter 621, Xu claimed the title of Prince of Lu as well.