LONDON: Newly released British intelligence files reveal how a Nazi spy was snatched from a boat on the high seas before he could warn Germany that an Allied convoy was steaming ahead to invade North Africa.

It was a little-known episode that changed the course of World War II.

Gastao de Freitas Ferraz, the radio operator on a Portuguese cod-fishing vessel, was secretly feeding Germany information about the movements of Allied ships in the North Atlantic.

The story of his capture, a week before the invasion by U.S. and British forces, is contained in previously secret documents from the MI5 security service released Tuesday by Britain's National Archives.

Cambridge University historian Christopher Andrew said the file "changes our understanding of British history" and offers new information on Britain's intelligence battle against the Nazis.

On Nov. 8, 1942, British and American troops under Gen. Dwight D. Eisenhower landed in Morocco and Algeria, which were occupied by the troops from Germany and the pro-Nazi Vichy French regime.

The French forces were quickly overcome, but German troops under Gen. Erwin Rommel resisted and pushed the Allies back. After fierce armored desert battles lasting into 1943, the Germans were defeated. It was a turning point in the war that helped lay the groundwork for the D-Day invasion of 1944.

But all that might have changed if Freitas Ferraz had not been captured.

Portugal was neutral during the war, but the files reveal that in 1942 British spies had become suspicious of "unnatural behavior" by Portuguese fishing boats, including ones with elaborate communications equipment.

Freitas Ferraz's boat, the Gil Eannes, was searched while in port at St. John's, Newfoundland, and MI5 decided the radio operator should be arrested.

But the documents show the detention was bungled in a series of errors. A frustrated MI5 officer named H.P. Milmo said he wasted valuable time trying to find out which government department was responsible for Newfoundland, then a British colony.

Officials then searched in vain for powers under which to detain Freitas Ferraz. But by the time the confusion cleared the Gil Eannes had sailed for Portugal, and officials made the risky decision to intercept it at sea.

Freitas Ferraz was arrested in a daring mid-Atlantic raid by HMS Duke of York on Nov. 1, 1942, and taken to Gibraltar and then Britain for interrogation. The MI5 file includes a detailed first-person biographical statement and confession. Freitas Ferraz was being paid 15,000 escudos a month to report to the Germans on the movements of Allied naval convoys and air units. The file notes that his job provided the "perfect cover."

MI5 agent Milmo, later a prosecutor at the Nuremberg trials and a High Court judge, reported that the Gil Eannes "was intercepted by the Royal Navy and de Freitas Ferraz was arrested when the vessel was about to sail into one of the large convoys carrying the British and American forces which occupied North Africa a week or so later."

Andrew, who is writing the official history of MI5, said the Germans had been "completely hoodwinked" by British deception before the invasion and believed the Allies would land in France or Norway.

"This would not have worked if Gastao de Freitas Ferraz had not been captured because he was on the tail of (Gen. George) Patton's troops, and would have told the Germans where they were really going," Andrew said.

"(That) could have affected the outcome of the whole war," he added.

Freitas Ferraz was deported to Portugal in 1945. In 1953, his name was included on a list of deportees who no longer needed to be banned from Britain for security reasons. In 1955, his file was marked closed.