WASHINGTON—Former House Speaker Dennis Hastert allegedly agreed to pay a former male student $3.5 million to keep secret allegations of sexual misconduct that took place before the Illinois Republican was elected to Congress, according to people familiar with the matter.

Mr. Hastert was indicted Thursday on charges related to large sums of cash he withdrew from bank accounts to pay someone identified in court papers only as "Individual A" to keep quiet about past "misconduct." According to the indictment, Mr. Hastert had committed the misconduct against the individual, who was from Yorkville, Ill., where the former speaker was a teacher and wrestling coach.

A federal magistrate set preliminary bail at $4,500 for Mr. Hastert and the case was assigned to U.S. Judge Thomas Durkin in Chicago. The bail amount, included in court documents made public Friday, will allow Mr. Hastert to stay out of custody until he is scheduled to appear in court for an arraignment. An arraignment hasn't yet been scheduled, but will probably take place in the coming days.

Mr. Hastert didn't respond to requests for comment Friday.

The individual is a man who allegedly said he had sexual contact with Mr. Hastert decades ago, according to the people familiar with the matter. In 2010, according the indictment, Mr. Hastert agreed to pay him $3.5 million over a period of years to keep him from revealing the misconduct.

A series of large cash withdrawals made bankers suspicious, so they questioned Mr. Hastert. After that, he began withdrawing money in increments of less than $10,000 each to avoid breaching a threshold above which banks must report transactions, according to the indictment. That, the Justice Department says, violated a law against "structuring" cash transactions to avoid the reporting requirement. Mr. Hastert is also charged with lying to the Federal Bureau of the Investigation about the purpose of the withdrawals.

With research by Lisa Schwartz

Write to Andrew Grossman at andrew.grossman@wsj.com, Devlin Barrett at devlin.barrett@wsj.com and Ben Kesling at benjamin.kesling@wsj.com

Subscribe to WSJ: http://online.wsj.com?mod=djnwires