After one year he was appointed Minister of Labour in the first cabinet Knudsen. During his tenure, there were several achievements; including the opening of the Rjukan Line and the Bergen Line railways. His seat in parliament was taken by Martin Løken in 1908 and 1909, and Ihlen was not re-elected in 1910. The first cabinet Knudsen fell in February 1910, but when the second cabinet Knudsen assumed office on 31 January 1913, Ihlen was appointed Minister of Foreign Affairs. He served through the entire World War I, during which Norway balanced on a thin line of neutrality. For some days in July 1918 he had also served as Minister of Industrial Provisioning. In June 1920 Ihlen resigned along with the rest of the second cabinet Knudsen, leaving national politics.