The gunman suspected of attempting to assassinate former President Donald Trump acted so erratically during his years as a pro-Ukraine activist that other Americans who encountered him flagged his behavior to U.S. authorities. Ryan Wesley Routh was taken into custody in Florida on Sunday after Secret Service personnel spotted and opened fire at a man pointing a rifle through the fence at a West Palm Beach club where Trump was golfing. The man fled in a black Nissan and was quickly apprehended.

But it was Routh’s time in Ukraine, where he traveled shortly after the Russian invasion in 2022 hoping to join the fight, where his tumultuous life full of failures and brushes with the law seemed to spiral further downward—and to alarm those who came in contact with him.

Chelsea Walsh, a nurse who had several encounters with Routh in Kyiv in 2022, said his threats of violence worried her so much that she conveyed her concerns to a Customs and Border Protection officer in an hourlong interview at Washington’s Dulles airport in June 2022.

Walsh told the officer during the interview, which took place after she returned to the U.S., that Routh was among the most dangerous Americans she met during her month-and-a-half-long stint in Ukraine.

She showed the officer a notebook listing more than dozen names of Americans and others whose actions had alarmed her, she recounted. Under the heading “Overall Predatory Behavior (or antisocial traits)” were four names. Routh’s was at the top.

When the officer noted that there were a lot of names, she replied, “‘Of all the people on there, Ryan Routh should be number one,’” Walsh told The Wall Street Journal, which reviewed her notebook.

Customs and Border Protection didn’t immediately respond to inquiries about the meeting.

Routh’s behavior had been flagged to the FBI in the past, though not in connection to Ukraine. A tipster told the FBI in 2019 that Routh had a firearm despite being a felon, but when questioned further wouldn’t verify providing the information, an FBI official said Monday. The bureau passed the information onto authorities in Honolulu, where Routh was living at the time, and closed the investigation.

His activities related to Ukraine brought him to the attention of a large group of people, many of whom quickly grew suspicious.

Routh was well known among volunteer aid groups in Ukraine as a “fraudster” and “kind of a whack job,” said Sarah Adams, a former CIA officer who helped run a network that linked 50 aid groups to share information and coordinate humanitarian and volunteer efforts. He claimed to be working with the Ukrainian government to recruit foreign fighters but wasn’t, she said.

Ukraine’s International Legion, which handles foreign volunteers, has denied having any ties with Routh.

“My name is Ryan Routh from the U.S.A.,” read one message viewed by the Journal, addressed to Afghan soldiers on Signal and WhatsApp, in which he claimed that he had “gotten the Ukraine Army to accept some Afghan soldiers on a trial-test basis.”

After being alerted to these messages in early June, other aid groups banned him from their Signal groups, and reported his activities to the State Department, noting their concerns that he might be engaging in human trafficking or immigration fraud, according to Adams. “Beware of American Ryan Routh,” Adams warned Ukraine aid groups in a June 2, 2023 message.

The State Department didn’t immediately respond to a request for comment.

“A lot of people were trying to get him to stop his activities, or at least prevent people from falling for his scams,” Adams said.

In Kyiv, Routh dyed his hair blue and yellow, the colors of the Ukrainian flag, and frequently wore a red, white and blue American-flag T-shirt. He put up official-looking posters around Kyiv urging foreigners looking for ways to aid Ukraine to text him.

A French man who traveled to Ukraine intending to fight said Routh helped secure him a spot in a Ukrainian army unit. However, he recalled the American voicing bitter anger at Trump when they met him over beers in Kyiv in 2022.

“Ryan was very upset about the fact that Trump was trying to negotiate a deal with Putin instead of trying to really have Ukraine’s back,” said the man, who asked not to be identified.

Walsh, the nurse from West Palm Beach, said she texted the number on one of Routh’s posters when she first arrived in Kyiv, thinking it would direct her to a volunteer organization.

Instead Routh asked her to meet him and others in Kyiv’s central square, known as the Maidan, the next day to hold up flags from different countries to make a statement about global support for Ukraine. She did, holding up an Irish flag. At that point, said Walsh, Routh seemed eccentric but not dangerous.

Her view of him changed during dozens of meetings and chance encounters they had in Kyiv, she said. He talked about wanting to kill Russian President Vladimir Putin and North Korea’s leader Kim Jong Un , Walsh recalled, saying he also mentioned Trump and President Biden, though Walsh said she couldn’t recall if he threatened them.

When she heard in 2023 that Routh was attempting to recruit Syrian refugees to fight in Ukraine, she filed an online report with the FBI and Interpol outlining her concerns about Routh and others, she said. Neither Customs nor the FBI followed up with her, she said. The FBI didn’t immediately respond to a request for comment.

But after the apparent attempt on Trump’s life Sunday, she called the FBI tip line and reported her concerns about Routh again in a 22-minute conversation.

Corrections & Amplifications undefined Ryan Wesley Routh was taken into custody in Florida on Sunday. An earlier version of this article incorrectly said Routh was taken into custody on Tuesday. (Corrected on Sept. 16)

Write to Deborah Acosta at deborah.acosta@wsj.com