The campaigning singer Pete Seeger, composer of classic American folk tunes including If I Had a Hammer and Where Have All the Flowers Gone?, was spied on by FBI agents for more than two decades because he wrote a protest letter as a young man concerned about plans to deport tens of thousands of Japanese American citizens at the end of the second world war.

A vast file on Seeger was released to the independent American news website Mother Jones in response to a request under the freedom of information act. It reveals that the bureau’s spies first took an interest in the singer in 1943. Seeger, a 23-year-old army private at the time, had written denouncing a plan for mass deportation drafted by the California chapter of the American Legion, a veterans’ association.

“If you bar from citizenship descendants of Japanese, why not descendants of English? After all, we once fought with them too. America is great and strong as she is because we have so far been a haven to all oppressed. I felt sick at heart to read of this matter,” he wrote.

His angry letter prompted close scrutiny of his political views and associations by the bureau that ran on into the early 1970s. The suspicion was that Seeger, who died in early 2014, was a security risk with close connections to the Communist party.

The FBI file on him has nearly 1,800 pages – 90 of them are still withheld for security reasons – and journalist David Corn has unearthed details within it of the elaborate efforts made by government agents to document Seeger’s activities, even back to his school days.

An agent sent out to his Connecticut high school found evidence that he had worn “bohemian” clothes. Another was sent to Harvard, where the singer had spent a year studying, and was told the student’s grades had been “fair” and that he had been secretary of the student union. Mililtary intelligence also contacted the performer Woody Guthrie, who had played with Seeger in a leftwing group called the Almanac Singers.

Seeger, who was later to become one of the earliest backers of Bob Dylan, inviting him to perform at the Newport Folk Festival, had been drafted into the army in 1942 and was trained as an aviation mechanic in Mississippi. His early letter of protest was quickly sent on to the FBI in San Francisco and within weeks military intelligence was investigating him and updating the bureau.

As a result, the young mechanic was not sent into action and became increasingly frustrated. He wondered if his engagement to a Japanese-American woman, Toshi Ohta, was a problem. At the time Seeger wrote to his grandmother: “It is possible that I am being held here because of my former connections with the Almanac Singers and because of my engagement to a Japanese-American, but I doubt it. I have never tried to hide either fact.”

Military intelligence also investigated Ohta herself and Seeger’s father, Charles, a noted musicologist. After setting up a fake pretext for an interview with his father, the agent was told the musician had “bummed around” the country, playing the banjo and singing and was “very much interested in the common people”. A friendship with the renowned folk singer Lead Belly was also examined. An official report described Lead Belly as “a negro murderer who escaped from prison a few years ago”. In fact Lead Belly was jailed for killing a relative, but was pardoned in 1925.

Guthrie was approached about Seeger in May 1943 and he told the government agent that Seeger could be trusted and should be put to good use by the army. But the agent’s report also noted that Guthrie’s apartment contained a guitar bearing the inscription: “This machine kills fascists.” “This bears out the belief that the Almanac Players were active singing Communist songs and spreading propaganda,” concluded the agent.

After the probe into Seeger’s background, a report judged that Seeger was “potentially subversive” and “an idealist whose devotion to radical ideologies is such as to make his loyalty to the US under all circumstances questionable”. The document was sent to J Edgar Hoover, director of the FBI.

The musician eventually joined the army division that entertained the troops. Yet he remained an FBI target after the war. Throughout the 1950s, when Seeger was part of the Weavers folk group, the bureau commissioned hundreds of reports on him, many tracking his musical performances. As the Weavers scored chart hits, Seeger was blacklisted for his suspected Communist party links.

In 1955 he was called before the House Committee on un-American Activities and asked if he was a communist. “I am not going to answer any questions as to my associations, my philosophical or religious beliefs or my political beliefs or how I voted in any election or any of these private affairs. I think these are very improper questions for any American to be asked,” Seeger replied. Two years later he was cited for contempt of Congress and then, four years later, found guilty and sentenced to a year in prison. Let free on bail, Seeger’s conviction was overturned a year later.

After a 1963 concert in Hawaii, an agent reported that an audience member had heard Seeger sing a song that was “low-keyed propaganda to the effect that America is a land of conformity” as well as a song from Japan about nuclear bombs.

Towards the end of his life Seeger became an environmental crusader who cruised the Hudson river in his sailing boat, Clearwater. Inducted into the Songwriters Hall of Fame in 1972, he was awarded a national medal of arts by President Clinton in 1994 and sang on the steps of the Lincoln memorial at one of President Obama’s inaugural concerts.

Seeger did acknowledge he had been in the Communist party in the 1940s and once said he should have left earlier.