The witness took a picture of the vehicle and number plate and it was stopped later in Martin County, north of the club.
"We got a hold of Martin County Sheriff's Office, alerted them, and they spotted the vehicle and pulled it over and detained the guy," said Sheriff Ric Bradshaw of Palm Beach County.
"After that, we took the witness that witnessed the incident, flew him up there and he identified as the person that he saw running out of the bushes, that jumped into the car," the sheriff told a news briefing.
In an email to his supporters, Trump said he was "safe and well".
"Nothing will slow me down," he wrote. "I will never surrender!"
The incident comes almost exactly two months after a gunman attempted to assassinate Trump at a rally in Butler, Pennsylvania, striking his ear.
The Secret Service confirmed in a post on X that they were investigating a "protective incident" involving Trump that took place shortly before 14:00 EST (19:00 BST) on Sunday.
Later Sheriff Bradshaw said "the Secret Service agent that was on the course did a fantastic job".
He added: "What they do is they have an agent that jumps one hole ahead of time to where the president was at and he was able to spot this rifle barrel sticking out of the fence and immediately engage that individual, at which time the individual took off.”
There is now a heavy security presence on the roads and in the waters around the former president's Mar-a-Lago property in Florida, and his nearby golf course at West Palm Beach.
US media, citing unnamed law enforcement officials, have named the suspect as Ryan Wesley Routh, 58, of Hawaii.
BBC Verify has found social media profiles matching that name. They indicate that Routh called for foreign fighters to go to Ukraine to battle against Russian forces.
Routh was charged and convicted of numerous offences in Guilford County, North Carolina, between 2002 and 2010, according to a law enforcement source who spoke to the BBC's US partner CBS News.
The offences included carrying a concealed weapon, resisting arrest, hit and run motor vehicle, driving with a revoked licence and possession of stolen property.
The White House said President Joe Biden and Vice-President Kamala Harris had been briefed about the golf course incident.
"I am relieved that the former president is unharmed," Biden said in a statement.
Harris is in a tight race against Trump in the presidential election - the 5 November vote is expected to hang on the results in a few key swing states.
Harris issued a statement saying "I am deeply disturbed by the possible assassination attempt of former President Trump today.
"As we gather the facts, I will be clear: I condemn political violence. We all must do our part to ensure that this incident does not lead to more violence."
She also said "I am thankful that former President Trump is safe" and praised the US Secret Service and police "for their vigilance".
Trump was injured while addressing a crowd in Butler, Pennsylvania, on 13 July when a gunman, Thomas Matthew Crooks, fired at him with an AR-15–style rifle from the roof of a nearby building.
The shooting left one audience member dead, while Crooks, 20, was killed at the scene by a Secret Service sniper.
The Secret Service faced intense scrutiny over how the shooter from Bethel Park, Pennsylvania, was able to open fire on the former president.
The director of the agency, Kimberly Cheatle, resigned within two weeks of the incident.