Former House Speaker Dennis Hastert allegedly agreed to pay a former male student $3.5 million to hush up allegations of sexual misconduct when Mr. Hastert was an Illinois high-school teacher before his election to Congress, said people familiar with the matter.

Mr. Hastert, the nation’s longest-serving Republican speaker, was indicted Thursday on charges related to large sums of cash he allegedly withdrew from bank accounts to pay someone identified in court papers only as “Individual A” to keep quiet about past “misconduct.”

The individual was from Yorkville, Ill., where the former speaker was a teacher and coach, according to the indictment. The indictment shocked Mr. Hastert’s former colleagues in Congress and people who knew him in Yorkville.

Mr. Hastert didn’t respond to requests for comment Friday. He will be allowed to stay out of custody until he is scheduled to appear in court for an arraignment, according to documents made public Friday.

An arraignment hasn’t yet been scheduled, but will likely take place in the coming days. The case has been assigned to Judge Thomas Durkin, a former federal prosecutor and litigator nominated to the bench by President Barack Obama in 2012.