WASHINGTON — President Donald Trump’s personal assistant, John McEntee, lost his White House job this week because an investigation found he was a frequent gambler whose habit posed a security risk, according to two people familiar with his departure.

A background investigation found that McEntee bet tens of thousands of dollars at a time, making him unsuitable for a sensitive position close to the president, according to a person with knowledge of the situation. There was no indication his gambling was illegal, but there was concern that the 27-year-old could be vulnerable to outside influence, the person said.

McEntee declined to comment.

The Wall Street Journal first reported the concerns about McEntee’s gambling.

McEntee, who had been one of the first staffers to join the Trump campaign and served as the president’s “body man” after Trump’s election, was escorted off the White House grounds Monday after being notified that he was being let go. McEntee was “very upset” to learn he was being terminated, according to one person, and complained he had done nothing improper.

White House press secretary Sarah Huckabee Sanders earlier this week declined to offer an explanation for his departure, saying, “We don’t comment on personnel issues.”

McEntee was a starting quarterback at the University of Connecticut and then worked as a production assistant at Fox News. He joined the Trump campaign as a volunteer in July 2015 after doggedly writing to the campaign’s website asking for a job. When no one responded, he offered to take a position responding to website email, according to Trump advisers. He eventually was hired as trip director, overseeing preparations for campaign events. “I bought into the message,” McEntee told Bloomberg News in 2015 of his decision to join Trump. “I was sick of the career politicians.”

After Trump’s victory, McEntee was named as the president’s special assistant and personal aide. When he joined the White House, he reported in his personal financial disclosure two primary assets: a bank account containing $100,000 to $250,000 and another containing $15,000 to $50,000.

McEntee’s cousin, Zac McEntee, serves as personal assistant to Treasury Secretary Steven Mnuchin.

John McEntee’s firing came as White House Chief of Staff John Kelly has sought to speed up the background investigations of staffers still awaiting security clearances.

Two White House advisers said they learned about McEntee’s gambling habit after his dismissal. His hasty exit from the White House upset a number of staffers in the building, who described him as a loyal aide who deserved a more ceremonious departure.

On Tuesday, Trump’s reelection committee announced that McEntee would join the campaign as a senior adviser for operations.

Alice Crites contributed to this report.