Republican era
The warlord Yan Xishan retained control of Shanxi from the Xinhai Revolution in 1911 to the end of the Chinese Civil War in 1949. Taiyuan consequently flourished as the center of his comparatively progressive province and experienced extensive industrial development. It was linked by rail both to the far southwest of Shanxi and to Datong in the north. Until 1949, Yan's arsenal in Taiyuan was the only factory in China sufficiently advanced to produce field artillery. In 1923, Yan facilitated the construction of the province's first airport, Taiyuan Chengbei Airport, which allowed him to further develop a small air force. Because Yan succeeded in keeping Shanxi uninvolved in most of the major battles between rival warlords that occurred in China during the 1910s and 1920s, Taiyuan was never taken from Yan by an invading army until the Japanese occupied it in 1937.
Yan was aware of the threat posed by the Japanese, and in order to defend against their impending invasion of Shanxi, he entered into a secret "united front" agreement with the Chinese Communist Party in November 1936. He then allowed agents under Zhou Enlai to establish a secret headquarters in Taiyuan. Yan, under the slogan "resistance against the enemy and defense of the soil", attempted to recruit young patriotic intellectuals to his government from across China. By 1936, Taiyuan had become a gathering point for anti-Japanese intellectuals who had fled from Beijing, Tianjin, and Northeast China. A representative of the Japanese army, speaking of the final defense of Taiyuan, said that "nowhere in China have the Chinese fought so obstinately".
From the occupation of Taiyuan to the Japanese surrender in 1945, the invaders continued to exploit Taiyuan's industries and resources to supply the Japanese army. After they surrendered surrendered to Yan Xishan, 10,000–15,000 Japanese troops, including both enlisted men and officers, decided to fight for Yan rather than return to Japan. Yan also retained the services of experienced and foreign-educated Japanese technicians and professional staff brought into Taiyuan by the Japanese to run the complex of industries that they had developed around the city.
Taiyuan was the last area in Shanxi to resist Communist control during the final stages of the war. After Communist forces captured Taiyuan Wusu Airport, its defenders were trapped within the city, facing food shortages and low morale. Taiyuan Qinxian Airport and an adjacent barracks was subsequently established in October 1948 in the Dayingpan area of the city, which was able to accommodate transport aircraft, while the barracks garrisoned the Second and Third Battalions. The existing Chengbei Airport was also reinforced, and two temporary backup airfields were established at Gelaogou and Honggou. The city was taken by Communist forces on 22 April 1949, after they surrounded Taiyuan and cut it off from all means of land and air supply. The capture required the support of 1,300 pieces of artillery. Many Nationalist officers subsequently committed suicide.