A former career US diplomat has been sentenced to 15 years in federal prison after admitting he worked for decades as a secret agent for communist Cuba.

Manuel Rocha, 73, will also pay a 500,000 dollar (£401,000) fine and co-operate with authorities after pleading guilty to conspiring to act as an agent of a foreign government.

In exchange, prosecutors dismissed more than a dozen other counts, including wire fraud and making false statements.

“Your actions were a direct attack to our democracy and the safety of our citizens,” US District Court Judge Beth Bloom told Rocha.

Rocha, who asked his friends and family for forgiveness, said: “I take full responsibility and accept the penalty.”

Prosecutors said details of what Rocha did to help Cuba remain classified and would not even tell the judge when the government determined he was spying for Cuba.

The State Department said on Friday it would continue working with the intelligence community “to fully assess the foreign policy and national security implications of these charges”.

Rocha’s sentence came less than six months after his arrest at his Miami home on allegations he engaged in “clandestine activity” on Cuba’s behalf since at least 1981, the year he joined the US foreign service.

His prestigious career included stints as ambassador to Bolivia and top posts in Argentina, Mexico, the White House and the US Interests Section in Havana.

In 1973, the year he graduated from Yale, Rocha traveled to Chile where prosecutors say he became a “great friend” of Cuba’s intelligence agency, the General Directorate of Intelligence (DGI).

Rocha’s post-government career included time as a special adviser to the commander of the US Southern Command and, more recently, as a tough-talking Donald Trump supporter and Cuba hardliner, a persona that friends and prosecutors said Rocha adopted to hide his true allegiances.