Cain, 74, learned of his diagnosis on June 29, nine days after attending a Trump rally in Tulsa, Oklahoma, where he and many others crowded together without wearing face masks aimed at preventing the spread of the novel coronavirus.
He spent most of July in an Atlanta-area hospital.
"Herman had an incredible career and was adored by everyone that ever met him, especially me. He was a very special man, an American Patriot, and great friend," Trump wrote on Twitter.
Many Trump supporters have rejected the advice of public health experts and refused to wear masks, which can prevent the spread of the virus, making their defiance a type of political statement.
Just before announcing his diagnosis on July 2, Cain posted support for not mandating masks at a July 4 event at Mount Rushmore in South Dakota that Trump was planning to attend.
"Masks will not be mandatory for the event, which will be attended by President Trump. PEOPLE ARE FED UP!" he tweeted.
In June, he tweeted: "Don't believe the scare stories. A serious look at the numbers tells you there's no second wave starting."
Messages of condolences poured in from prominent conservatives, while some liberals used the occasion to promote the wearing of masks.
"Herman Cain will be missed, he was one of the greatest conservative voices of all time. I'll never forget his smiling face," Jenny Beth Martin, a co-founder of the Tea Party Patriots, wrote on Twitter.
Cain, who called himself an ABC man - "American Black Conservative" - had just started hosting a new show on Newsmax TV and hoped to play a role in the 2020 presidential election campaign, the statement said.