The Battle of the North Atlantic was the longest continuous military campaign of World War II, running from 1939 until the defeat of Nazi Germany in 1945, though it reached its peak from mid-1940 through the end of 1943. The Battle of the North Atlantic pitted German U-boats and other warships of the German navy against Allied merchant shipping. Initially, convoys of merchant ships were protected for the most part by the British and Canadian navies and air forces. Starting in the early fall of 1941, before Pearl Harbor, these forces were aided by ships and aircraft of the United States. The Battle for the North Atlantic began on the first day of the European war and lasted for six years, involving thousands of ships and stretching over hundreds of miles of the vast ocean and seas in a succession of more than a hundred convoy battles and as many as a thousand single-ship encounters. Tactical advantage switched back and forth over the six years as new weapons, tactics, and countermeasures were developed by both sides. The Allies gradually gained the upper hand, driving the German surface raiders from the ocean by the end of 1942 and decisively defeating the U-boats in a series of convoy battles between March and May 1943.