Independent U.S. presidential candidate Robert F. Kennedy Jr. had a parasite in his brain more than a decade ago, but has fully recovered, his campaign said, after the New York Times reported about the ailment.

Citing a 12-year-old deposition, the Times said Kennedy stated that a doctor had told him an abnormality on his brain scan "was caused by a worm that got into my brain and ate a portion of it and then died."

Kennedy "travelled extensively in Africa, South America, and Asia in his work as an environmental advocate, and in one of those locations contracted a parasite," Kennedy spokeswoman Stefanie Spear told Reuters.

"The issue was resolved more than 10 years ago, and he is in robust physical and mental health," she said.

Kennedy, who is challenging Republican former president Donald Trump and Democratic President Joe Biden for the White House in November, could pick up eight per cent of voters nationwide, a Reuters/Ipsos poll in March showed.

Kennedy took to the social media platform X to make light of the health scare.

"I offer to eat 5 more brain worms and still beat President Trump and President Biden in a debate," Kennedy said.

The 2012 deposition came during divorce proceedings from his second wife, Mary Richardson Kennedy, the Times reported, as he argued his earning power had been diminished by his cognitive struggles.

Mary Richardson Kennedy died by suicide in 2012, as she and Kennedy were battling over custody of their four children.

"Questioning Mr. Kennedy’s health is a hilarious suggestion, given his competition," Spear said.

(Reporting by Heather Timmons and Jarrett Renshaw; editing by Jonathan Oatis and David Gregorio)