A Republican congressional candidate and former Marine who suggested last year that he was tracking a U.S. ambassador who had fallen out of favor with President Trump was once involuntarily committed to a psychiatric hospital after an incident at one of the president’s resorts and is the subject of a restraining order obtained by a political consultant, police and court records show.

On Tuesday, Robert F. Hyde became the latest figure to emerge in the drama surrounding the Trump administration’s recall last year of Marie Yovanovitch as the U.S. ambassador to Ukraine when his 2019 messages were made public on the eve of Trump’s impeachment trial. His exchanges with an associate of Rudolph W. Giuliani, Trump’s personal attorney, had been turned over to House Democrats in response to a subpoena.

In the messages to Lev Parnas, Hyde claimed to be in contact with a “private security” team near the embassy in Kyiv and suggested that he had the ambassador under physical and electronic surveillance. “It’s confirmed we have a person inside,” he wrote in March.

Yovanovitch has called for an investigation into his claims. The State Department did not respond to messages seeking comment.

Giuliani had aggressively sought Yovanovitch’s ouster, and other material from Parnas released by House Democrats this week shows Ukraine’s then-top prosecutor appeared to offer damaging information on Democratic presidential candidate Joe Biden if Giuliani could secure her removal.

Hyde suggested in a television interview on Wednesday that he was joking in his WhatsApp messages to Parnas. Asked by Eric Bolling of the Sinclair Broadcast Group whether he had monitored Yovanovitch, Hyde said: “Absolutely not. You kidding me?”

As for Parnas, he said, “I barely know the guy.”

Hyde, 40, did not respond to specific questions from The Washington Post late Wednesday.

On his social media accounts, Hyde, a long-shot candidate for Congress in Connecticut’s 5th District, has posted numerous photos of himself and Trump or members of the president’s family, many of them taken at Trump properties. He appeared grinning with Trump on Easter at the president’s Mar-a-Lago resort in Palm Beach, Fla.

Among the photos and videos is a picture from a party to which, according to the post, Hyde had taken friends on May 7 at a bowling alley in the White House complex.

The bowling party occurred about a week before police were called to Trump’s Doral resort in Miami-Dade County for a “male in distress fearing for his life,” according to a police report from the incident.

Hyde told officers that he had been “set up and that a hit man was out to get him,” officers wrote. Hyde “spoke about emails he sent that may have placed his life in jeopardy” and said he believed that painters and landscape workers were trying to harm him and that the Secret Service was watching him.

Doral police classified the May 16 episode as a “Baker/Marchman Act” incident, referring to the Florida laws that allow a person to be involuntarily detained and treated for mental illness or substance abuse.

In a now-deleted social media post at the end of May, Hyde described being “Baker Acted” for nine days. “I passed all medicals, physicals, psych exams and diagnosis with flying colors . . . So in all honesty, eff you and your intelligence agencies, whatever or whoever was or is effing with me.”

One week after the incident in Doral, a 34-year-old political consultant obtained a temporary protection order against Hyde because of “constant harassment and stalking,” according to records in Superior Court of the District of Columbia. The consultant alleged that several incidents occurred at the Trump International Hotel in the District.

Hyde at one point was recruiting clients as an independent contractor for the woman’s firm, according to court records, but she let him go because of “subpar performance” as well as complaints from two female employees of “inappropriate behavior and advances,” she said in her request for a court protective order.

In her complaint, the consultant said Hyde had begun tracking her in December 2018.

In one instance, she alleged, Hyde ran across the lobby of the Trump hotel, “shoved my colleague out of the way to try and grab and hug me.” Other times, she wrote that Hyde had waited for her to leave events, tracking her once at a meeting with a Trump Cabinet secretary and another time dashing out from a hotel restaurant to follow her. Hyde “stalked me at hotel and I had to have a colleague walk me to elevator for safety,” she wrote.

A D.C. Superior Court judge issued a protective order that extends until June 2020. Hyde has appealed the order.

Hyde was also accused of violating the restraining order last year in the Boston area, according to Malden District Court records and the prosecutor’s office. Hyde’s attorney in the matter, Thomas Paul Polito, could not be reached for comment late Wednesday.

Kelsey Penna, the attorney listed as representing Hyde in Washington, said Hyde was no longer a client.

The consultant requested anonymity, citing fear for her safety.

Hyde served in the Marines from 1999 to 2005. He was stationed for part of that time in Bahrain and left with the rank of corporal, military records show. He then ran a landscaping business he’d founded in Connecticut, business records show.

The head of the Connecticut state Republican Party, J.R. Romano, said in a tweet Wednesday that he had asked Hyde — who is competing for his party’s nomination — to end his campaign. Romano wrote that it had become a “distraction for the Democrats to raise money and falsely label all Republicans with his antics.”

GOP legislative leaders had previously urged Hyde to drop out of the race after he posted an offensive tweet with sexual innuendo about Sen. Kamala D. Harris (D-Calif.) following her decision to drop out of the presidential race.

On the campaign trail, Hyde has said he was never very interested in politics until Trump became a candidate for president. Since Trump’s victory, Hyde has donated about $55,000 to the president’s inaugural campaign and to the Republican National Committee, records show.

Neil W. McCabe, a political reporter for One America News who also served in Iraq, said that he met Hyde at the Trump hotel in Washington last year and that they struck up a friendship. Sometimes Hyde would bring his “comfort dog” with him to the hotel, McCabe said.

“He’s a very generous, gregarious guy, a guy you would love to have dinner and drinks with, but has episodes where he sort of loses himself, and it’s really sad,” he said. “I know he saw combat as a Marine in Iraq, and I can’t help but think that some of this is combat stress.”

McCabe said he was skeptical that Hyde was serious about pursuing Yovanovitch.

In an MSNBC interview Wednesday with Rachel Maddow, Parnas described Hyde as a “weird” person who frequented the bar at the Trump hotel in Washington and who insinuated himself into the Ukraine business. Parnas called Hyde’s messages about Yovanovitch disturbing, but he said he did not take them seriously and did not think Hyde was in fact monitoring the U.S. ambassador to Ukraine.

Parnas was arrested in October along with an associate, Igor Fruman, on charges they schemed to funnel foreign money to U.S. politicians while trying to influence U.S.-Ukraine relations. Both men have pleaded not guilty.

Dalton Bennett, Shawn Boburg, Alice Crites, Richard Leiby, Rosalind S. Helderman and Tom Hamburger contributed to this report.