The agent, known by the alias Jack King, infiltrated a group of pro-German activists in south-east England in a previously unknown wartime operation.
His undercover work led to the identification of hundreds of people willing to pass secrets to the enemy.
Files in the National Archives describe King as a "genius" at his work.
By Gordon CoreraSecurity correspondent, BBC News
We had known that MI5 controlled German spies dropped into the UK under the Double Cross system but little was known about operations to control domestic sympathisers. This one began in a low-key manner with a correspondence club in which lonely people would write to each other but it would lead to the identification of potentially hundreds of people in Britain willing to help the Nazis.
Since Britain was never invaded, it's impossible to know how the country would have actually reacted, but the files suggest there were at least a few hoping for Hitler to take over and actively offering assistance.
The role of the MI5 agent Jack King is also intriguing. Quite who he was seems something of a mystery but senior officials in MI5 clearly rated him highly for his ability over years to undertake risky work in reeling in more and more Nazi sympathisers by convincing them he was linked to the Gestapo - and doing so without ever getting too close to provoking them to do anything too damaging.
In 1942, King - also referred to as SR in the files - met Marita Perigoe, described as a "crafty and dangerous woman" of Swedish and German origin.
Despite being married to a member of Oswald Mosley's British Union of Fascists, she had no time for the group and regarded them as "insufficiently extreme".
MI5 said of her: "She was found to be so violently anti-British and so anxious to do anything in her power to help the enemy that it was felt that special attention should be paid to her."
It went on to say she was not a "neurotic nor feminine type; she is masterful and a somewhat masculine woman".
"Both in appearance and mentality she can be described as an arrogant hun."
King managed to convince her that he was a representative of the Gestapo looking for people who were "100% loyal to the Fatherland" and could be relied on in the event of an invasion.
He exploited the group's taste for the cloak-and-dagger aspects of espionage work by offering them invisible ink for secret communications and arranging meetings in the basement of an antiques shop.
MI5 regarded some members of the group as unstable but warned they were still dangerous.
Hilda Leech was "unstable and neurotic" and was trying to pass on reports of highly secret research on jet aircraft, while astrologer Edgar Whitehead  - a "bit of a mystery man" - was passing on information about secret trials on an amphibious tank.
MI5 drew up plans to issue members with special badges to be worn in the event of an invasion - supposedly to identify them as friends to the Germans but in fact to enable them to be swiftly rounded up by the police.
By the end of the war, Perigoe was one of six agents working directly to King - all but one of them British.
MI5 estimated the number of their contacts who had been the subject of King's intelligence reports ran "certainly to scores and probably to hundreds".
In other declassified files released by the National Archives, it emerged that English actor Michael Redgrave met Guy Burgess, one of the Cambridge spies, while his theatre group toured Moscow.
The meeting in 1958 with his old friend from Cambridge University proved to be of interest to MI5, which was desperate to find out all it could about what was said.
Burgess, who had fled to Russia seven years earlier, turned up drunk at the theatre where Redgrave was starring in Hamlet.
But the two had lunch together the following day at Burgess' flat, provided by the KGB after his defection.
The British ambassador at the time said Redgrave had not been very communicative about the meeting and had not consulted the embassy about it beforehand.
Burgess, however, wrote a letter home to his mother - intercepted by MI5 - delighting in the "fine gossips" shared and gushing over Redgrave's acting.
"It's certainly the best Hamlet I've ever seen - better than Gielgud, better than Olivier, much better than Paul Schofield."
An MI5 agent pretending to have Gestapo links secretly controlled a vast network of UK-based Nazi sympathisers, newly-released files reveal.