Corporate lawyer Matthew Kluger is alleged to have been at the heart of one of the largest and longest-running insider-trading schemes ever prosecuted, but when he appeared in a federal court in Alexandria on Wednesday, he said he could not afford an attorney, according to a Justice Department spokesman.

The government says the scheme netted more than $32 million in illegal profits since 2006, but the case against Kluger leaves open the possibility that a trader in New York pocketed the vast majority of the gains and that Kluger never got rich from the trades.

In the Securities and Exchange Commission’s explanation of how the money was distributed, the agency said only that Kluger “has profited by at least $500,000.”

Kluger, 50, was assigned a public defender, Rachel Martin, who declined to comment Thursday.

He was being held in federal custody pending a bail hearing Friday.

If the charges the government filed against Kluger are true, he stole secrets about corporate deals from some of the nation’s most respected law firms over a 17-year span and exposed the vulnerability of their most sensitive client confidences.

The government alleges that Kluger passed tips to an unnamed friend who then conveyed them to Garrett D. Bauer, a trader in New York. After the trader bought and sold stock based on the tips, he allegedly shared some of the money with the go-between, who then passed a cut of it to Kluger.

Though Kluger’s position at major law firms gave him access to market-moving information about planned mergers and acquisitions, even on the surface, his career was far from conventional.

From an education in hotel management to years spent in car sales and a recent move into transportation safety, according to a law firm bio and a LinkedIn profile, he followed a winding path.

At an age by which many lawyers have made partner, he had worked for several firms and was a senior associate.

And in 2002, having left the Fried Frank law firm after about a year there, he sued the firm, alleging that it discriminated against him, law firm spokeswoman Wendy Bernero said. The case was settled confidentially, Bernero said after the Wall Street Journal reported on the matter.

According to Reuters Legal, the lawsuit alleged that he was told that partners were no longer comfortable working with him after they learned he was gay. Kluger asserted that he was told to find a new job after he took paternity leave to attend to his newborn twins, who were carried by a surrogate mother, Reuters reported.

At Kluger’s home on a quiet suburban street in Oakton, a man who came to the door Thursday quickly closed it when a reporter identified herself. Phone calls to the home were not returned.

Some of Kluger’s neighbors said they did not know the lawyer. Others seemed visibly uncomfortable or upset at the mention of Kluger’s ordeal and implied they knew him or his family but would not comment further.

Kluger purchased the house in 2005 for $945,000, according to land records.

The price was modest compared with the $6.65 million that the government says Bauer, the trader, spent on a Manhattan condo.

When Bauer was arrested at his home Wednesday, the government seized trading accounts from him containing $20.5 million, and a government lawyer told a court that his assets were estimated at $70 million, said Rebekah Carmichael, a spokeswoman for the U.S. attorney in New Jersey.

Investigators believe Kluger and Bauer might have met once or twice over 17 years, and it is possible Kluger did not know how much money Bauer was wagering on Kluger’s tips, said Daniel M. Hawke, chief of the SEC’s market abuse unit.

The two tried to eliminate the risk of getting caught by using a go-between instead of communicating directly, but investigators picked up on a pattern of suspicious trading attributable to Bauer, Hawke said.

Staff researcher Lucy Shackelford and Capital Business staff writer Amanda Becker contributed to this report.