Mannerheim made a career in the Imperial Russian Army, rising by 1917 to the rank of lieutenant general. He had a prominent place in the ceremonies for Tsar Nicholas II's coronation in 1896 and later had several private meetings with the Tsar. After the Bolshevik revolution of November 1917 in Russia, Finland declared its independence – but soon became embroiled in civil war between the pro-Bolshevik "Reds" and the "Whites", who were the troops of the Senate of Finland, supported by troops of the German Empire. Mannerheim was appointed to the military chief of the Whites, by a Finnish delegation. Mannerheim was appointed as Commander-in-Chief of the country's armed forces in 1939 after the failed Soviet invasion of Finland. He also personally participated in the planning of Operation Barbarossa and led the Finnish Defence Forces in an invasion of the USSR alongside Nazi Germany known as the Continuation War. In 1944, when the prospect of Germany's defeat in World War II became clear, the Finnish Parliament appointed Mannerheim as President of Finland, and he oversaw peace-negotiations with the Soviet Union and the UK. He resigned from the presidency in 1946 and died in 1951.