WASHINGTON — President 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.

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 that 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.