The security services kept a file on the former Labour Prime Minister Harold Wilson throughout his time in office, a new book has revealed.
Defence of the Realm, the first authorised history of MI5, says there were worries about his relationships with Eastern European businessmen.
His contact with KGB officers also raised concerns.
However, the book, serialised in the Times, dismisses long-standing claims of bugging and plots against him.
Mr Wilson, who died in 1995 aged 79, was the only serving prime minister to have a permanent Secret Service file, according to the book's author Cambridge professor Christopher Andrew.
MI5 opened the dossier in 1945 when Mr Wilson became an MP after communist civil servants suggested he had similar political sympathies.
His file was so secret that he was given the pseudonym Norman John Worthington.
Sir Michael Hanley, MI5 director general from 1972, went to even greater lengths to conceal its existence by removing it from the central index, meaning any search would result in a "no trace".
Personal permission from Sir Michael was required to access it.
In his later years in office, Mr Wilson became increasingly obsessive about his belief that the secret services were bugging him and plotting against him.
The Times quotes from the book: "Sitting in his study at Number Ten on his first day back in office [in February 1974], Wilson told [his business friend who Sir Michael Hanley said was not to be trusted with confidences] Lord Kissin of Camden 'there are only three people listening - you, me and MI5.
"Though MI5 was not, of course, listening in to the Prime Minister and had never actively investigated him, it still had a file on him which recorded, inter alia, his past contacts with Communists, KGB officers and other Russians."
Harold Wilson, Labour leader for 13 years, led the country from 1964 to 1970, and then again from 1974 to 1976.
During his premiership, policies such as the decriminalisation of homosexual practices and the legalisation of abortion were introduced.
His government is also remembered for the deteriorating relations with trade unions and the devaluation of the pound in 1967.
The book, to be published next week, will mark MI5's centenary.