Finland was actively involved in hostilities during World War Two. The Soviets invaded Finland on November 30, 1939 as Stalin claimed that Finnish troops opened fire on Soviet troops, and in March 1940, negotiations with the Soviets began, and Finland signed the Treaty of Moscow, which ceded territory to the Soviets.

As tension increased between Germany and the USSR, Finland saw that Hitler could be a possible ally in gaining back the territory that it had lost.

As a result of this, German troops were allowed on Finnish soil as the Germans prepared for their invasion of the Soviet Union—a war that the Finns eagerly joined.

So Finland initially sided with Nazi Germany and acted as a 'co-belligerent' against the Soviet Union in what was known as the Continuation War (1941–1944).

It is important to note that Finland was largely dependent on food, fuel and armament shipments from Germany during this time, and this too was influential in the Finnish decision.

As the tide turned against Germany, Finland saw that their initial aims of siding with Germany against the Soviets was not in the interests of Finland, so on the 3rd of March, 1945, Finland formally declared war on Germany.

By the end of the hostilities, Finland had indeed managed to defend its independence, but at a great cost; having to cede nearly 10% of its territory, including its second largest city, Viipuri, and pay out a large amount of war reparations to the Soviet Union.

More Info: en.wikipedia.org