Li served as president from 7 June 1916 to 17 July 1917. When Yuan died, he left a will containing Li's name along with Premier Duan Qirui and Xu Shichang. The will was an imperial tradition started by the Kangxi Emperor, and was not constitutional in the republic. Nevertheless, the Beiyang generals pressed Li into office, since he was acceptable to the rebellious southern provinces. Li tried to return to the 1912 constitutional arrangement, but Duan held the real power. The National Assembly of the Republic of China reconvened on 1 August 1916, after having been disbanded over two and a half years earlier. Duan was eager to pull China into World War I but Li was more hesitant. They conflicted greatly over Duan's decision to cut ties with Germany. Li forced Duan to resign on 23 May 1917, when the premier's secret loans from Japan were exposed. Duan fled to Tianjin to muster his forces, and most generals abandoned the government. In response, Li asked General Zhang Xun for assistance. In exchange, Zhang asked for the dissolution of parliament which was granted on 13 June. Zhang, who was secretly pro-German, unexpectedly occupied Beijing from 14 June to 12 July 1917 and kept the president prisoner. Zhang then proceeded with a move that would undermine most of his support when he attempted to restore Emperor Puyi and the Qing dynasty on 1 July. Li was released to the Japanese legation where he asked for Duan's assistance in saving the republic. Duan overthrew Zhang within two weeks, and restored the republic by 12 July; Duan himself was reinstated as premier by 14 July. Vice President Feng Guozhang was made acting president in Nanjing. On 17 July, distraught from recent events, Li officially resigned from office and moved to Tianjin in retirement.