Lin Xuan transmigrated to a mass grave outside Lin'an in the fifth year of the Jingding era under Emperor Lizong of the Song. After witnessing Mongol cavalry slaughter civilians, he used his modern military knowledge to save Zhao Da and obtain a fragment of The Essentials of the Military Classics. At the time, Jia Sidao held unchecked power, the Song-Mongol war was at a stalemate, and the powerful families within Lin'an were rife with corruption. Under the slogan "Give land to the tillers and abolish taxes," Lin Xuan organized a rebel army. Disguised as a refugee, he uncovered evidence of the Zhou family's dealings with Mongol merchants. After burning their granary, he was hunted down and fled to the slums, where he met Su Jin. He later joined forces with the rebels to attack the Zhou family, winning great renown, but the court sent people to investigate him, forcing him to flee to Sichuan.
In Sichuan, he won Zhang Hu over and formed the Swiftwind Battalion. Though ambushed along the way, he used firearms to inflict heavy losses on the enemy. He then pretended to submit to Yu Jie and entered Diaoyu Fortress. Lin Xuan unraveled the Mongol navy's tactics, making Yu Jie wary of him. Yu Jie was assassinated by one of his own men during a banquet, and Lin Xuan took control of Diaoyu Fortress. When Jia Sidao sent troops to crush him, Lin Xuan repelled the Song army and forced Lü Wende to make peace with the Mongols. Later, he feigned submission to the Mongols to gather intelligence, then joined forces with Dali to train a navy and launch a nighttime raid on Mongol supply ships. After inflicting heavy losses on the Mongols, he was appointed Commander of Sichuan.