Sam Bankman-Fried, the founder of the collapsed cryptocurrency exchange FTX, was sent to jail on Friday after a federal judge in New York revoked his bail, accusing him of trying to influence witnesses who are poised to testify against him at a widely anticipated trial in less than two months.

Mr. Bankman-Fried, 31, had been under house arrest at his parents’ home in Palo Alto, Calif., since he was arrested in December on fraud charges stemming from FTX’s implosion. But at a hearing on Friday, Judge Lewis A. Kaplan of Federal District Court in Manhattan said that arrangement would have to end, after prosecutors argued that Mr. Bankman-Fried had twice tried to interfere with witnesses in the case, including by giving documents to reporters.

“He has gone up to the line over and over again, and I am going to revoke bail,” Judge Kaplan said from the bench.

After the order was read aloud, two U.S. marshals had Mr. Bankman-Fried remove his tie and navy suit jacket as they prepared to handcuff him. His mother, Barbara Fried, in attendance with his father, tried to approach him, but a court officer cautioned her to stand back. He was taken to the Metropolitan Detention Center in Brooklyn.

One of Mr. Bankman-Fried’s lawyers, Mark Cohen, said in court that he intended to appeal. Judge Kaplan said he wouldn’t wait for the outcome of that effort before sending Mr. Bankman-Fried to jail.

The courtroom scene was the latest humiliating blow to Mr. Bankman-Fried since his cryptocurrency company fell apart in one of the most stunning corporate crashes in recent history. FTX rode the highs of the virtual currency market to become one of the industry’s leading companies before filing for bankruptcy after a run on deposits last fall. Over a few weeks, Mr. Bankman-Fried went from being an industry titan courted by politicians and celebrities to a criminal defendant facing decades in prison.

Now he will have to prepare for his trial, scheduled to begin Oct. 2, from a jail cell.

The court dispute over his bail focused on a New York Times article, published last month, that described private writings by Caroline Ellison, an executive in Mr. Bankman-Fried’s business empire who had also dated him. Ms. Ellison has pleaded guilty to fraud charges and agreed to cooperate with the prosecutors investigating Mr. Bankman-Fried.

In court filings, prosecutors said Mr. Bankman-Fried had given the documents to The Times to intimidate Ms. Ellison by casting her in a negative light before his trial. They also noted Mr. Bankman-Fried’s numerous conversations with others in the media, including the author Michael Lewis, who is writing a book about FTX that is set for publication the week the trial begins.

As the bail issue was debated in court filings over recent weeks, Judge Kaplan imposed a temporary gag order preventing the FTX founder and his representatives from speaking to the media.

Lawyers for Mr. Bankman-Fried said that by giving the documents to The Times, he had been exercising his right to answer “an inquiry from the media” and had not breached the terms of his bail agreement. The Times, the Reporters Committee for Freedom of the Press and a documentarian making a film about Mr. Bankman-Fried each submitted a court filing raising First Amendment concerns about the gag order.

The status of the order was not immediately clear after Mr. Bankman-Fried was sent to jail on Friday. But in court, Judge Kaplan said that “defendant speech is not protected if it is to bring about a crime.”

He said he had concluded that Mr. Bankman-Fried’s communication with the media and a separate attempt to contact a former FTX employee were intended to “intimidate or also to influence” witnesses in the case.

A spokesman for Mr. Bankman-Fried declined to comment. A spokesman for the U.S. attorney’s office for the Southern District of New York, which is prosecuting Mr. Bankman-Fried, did not respond to a request for comment.

Mr. Bankman-Fried was arrested in the Bahamas, where FTX was based, after the company collapsed during a turbulent week in November. He was charged with using customers’ deposits to finance lavish real estate purchases, political donations and charitable initiatives. After a few days in jail in the Bahamas, he was extradited to the United States and released on highly restrictive bail conditions that required him to wear an ankle monitor and confined him to his parents’ house. He has pleaded not guilty.

Since his release, Mr. Bankman-Fried has been reprimanded repeatedly for behavior that prosecutors said pushed the boundaries of what he was allowed to do while awaiting trial.

In court filings in January, the prosecutors presented evidence that he had sent messages to a former FTX executive who could be a witness in the case, asking to speak with him. They also said Mr. Bankman-Fried had used a virtual private network, or VPN, a tool they claimed could disguise how he was using the internet while awaiting trial.

At the time, Judge Kaplan ordered Mr. Bankman-Fried to submit to tighter bail requirements that restricted which websites he could use and prevented him from communicating with former FTX employees. Visitors to his parents’ house were prohibited from taking phones or computers inside.

While it’s uncommon for bail to be revoked, especially so close to a trial date, it does happen when judges are convinced that the defendant’s actions pose a threat to the community or to witnesses.

Judges have a “good bit of discretion” on revoking bail, said Erik Gordon, a law and business professor at the University of Michigan. “If you are out on bail, you don’t want to come within a mile of doing anything that could be seen as an attempt to coerce a witness.”

The Times’s article about Ms. Ellison included excerpts from private Google documents addressed to Mr. Bankman-Fried, with raw reflections on their relationship and her insecurities about her role as chief executive of Alameda Research, a hedge fund that Mr. Bankman-Fried founded. In court, prosecutors argued that the sensitive nature of the writings showed that Mr. Bankman-Fried was seeking to intimidate and discredit his former girlfriend.

“No set of release conditions can assure the safety of the community,” Danielle Sassoon, one of the prosecutors, said at a hearing last month. “The defendant has shown now that he is intent on exploiting the conditions of release and improperly influencing this trial.”

For Judge Kaplan, the article about Ms. Ellison was the final straw. Mr. Bankman-Fried’s messages to the former FTX executive, who served as general counsel of the firm’s U.S. arm, seemed designed to get him to “sing from the same hymnbook,” Judge Kaplan said on Friday. And by sharing documents with The Times, he said, Mr. Bankman-Fried intended to “portray Ms. Ellison in an unfavorable light.”

As Mr. Bankman-Fried’s lawyers fought to keep the bail agreement in place, they argued that conditions at the Brooklyn detention center would make it difficult for him to prepare for the trial.

Judge Kaplan said he was open to the possibility of transferring Mr. Bankman-Fried to a facility that would offer more consistent internet access, like a detention center in Putnam County, N.Y. He said he was also willing to consider an arrangement that would allow Mr. Bankman-Fried to meet with his lawyers at their office, under heavy security.

For now, though, Mr. Bankman-Fried will be housed at the federal facility in Brooklyn. In court filings, his lawyers argued that the jail was facing a “staffing crisis” and that people held there typically had limited computer access.

The location is “not on anyone’s list of five-star facilities,” Judge Kaplan acknowledged on Friday.

Santul Nerkar contributed reporting.