CHICAGO—Former House Speaker Dennis Hastert will plead guilty to charges that he lied to the FBI about making illegally structured bank transactions as part of an effort to pay hush money to someone he wronged in the past, prosecutors and his attorneys said in court Thursday.

With the announcement of the plea agreement, Hastert, 73, may be able to keep embarrassing details about his past out of the public eye, but it could mean serving time in prison.

Lawyers confirmed Thursday in court that Hastert will plead guilty on Oct 28. Joseph Fitzpatrick , a spokesman for the U.S Attorney for the Northern District of Illinois, said  “principles of an agreement” have been reached, but did not reveal which charges Hastert would admit to or whether the agreement includes prison time for the former speaker. Attorneys are scheduled to deliver a draft of the plea agreement by Monday.

Hastert, the longest-serving GOP speaker in history, was indicted in May on charges that he lied to the FBI and made illegally structured bank payments totaling more than $1.7 million as part of a plan to pay hush money for unspecified past misconduct to someone only identified as “Individual A”.  Prosecutors had said that he agreed to make a total of $3.5 million in payments before he was indicted.

Hastert, who served 20 years in Congress that included nearly nine years as speaker of the House, taught and coached at Yorkville High School from 1965 to 1981.

While the indictment doesn’t detail the wrongdoing against the unnamed individual, law enforcement officials previously told USA TODAY that the former lawmaker made the payments to conceal sexual misconduct committed against a male student decades earlier when he worked at Yorkville High in what was then a semi-rural community west of Chicago. The officials, who were not authorized discuss the sensitive matter publicly, spoke on the condition of anonymity.

Since the indictment was unsealed, Hastert’s lead defense attorney, Thomas Green, twice complained to Judge Thomas Durkin that leaks to the media about the nature of his alleged misconduct have put an unfair burden on his client.

Green called the allegations against Hastert the “800-pound gorilla” in the case and accused the government of making “unconscionable leaks.”

Steven Block, the assistant U.S. attorney who was the lead prosecutor in the case, denied in court that his office was behind the leaks.

The Republican from Illinois was charged with circumventing a federal filing requirement that requires banks to report withdrawals of more than $10,000. He withdrew a total of $952,000 in increments under the threshold that were then paid to the individual. Federal law requires banks to file what are known as “currency transaction reports” on withdrawals exceeding the threshold. The reporting requirement is meant to prevent or flag money laundering and other financial crime.

When queried about suspect withdrawals by the FBI in December 2014, Hastert allegedly lied and said he was keeping the cash, according to the indictment. Agents asked Hastert if he was withdrawing the money because he did not feel safe with the banking system. Prosecutors said in their filing that Hastert responded: “Yeah . . . I kept the cash. That’s what I’m doing.”

Hastert and the individual allegedly sat down in about 2010 to discuss the misconduct that had occurred years earlier, according to prosecutors. The former speaker allegedly agreed in that meeting and subsequent meetings to pay a total of $3.5 million.

From 2010 to 2014, Hastert withdrew a total of approximately $1.7 million in cash from various bank accounts and provided it to the person who is identified in the indictment as “Individual A,” the indictment said.

Between June 2010 to April 2012, Hastert made a total of 15 withdrawals of $50,000 each from a personal bank account, court records show. The individual was paid approximately every six weeks during that period, according to the indictment. In July 2012, Hastert started making cash withdrawals in smaller increments allegedly to avoid triggering the federal filing requirement on transactions.

After the indictment became public, Jolene Burdge, the sister of a former wrestling team manager for Hastert at Yorkville High, alleged that her brother, who died of AIDS in 1995, confided to her that he was the victim of sexual abuse by Hastert when he was a teen.

Separately, a former House colleague of Hastert said that years earlier he heard an allegation of past sexual misconduct against Hastert, but did not alert authorities. The colleague, Federal Housing Finance Agency Director Mel Watt, a former Democratic lawmaker from North Carolina, said he did not take action because he had “no direct knowledge of any abuse” by Hastert.

Going to trial could have potentially proven challenging for both Hastert and federal prosecutors, said Ellen Zimiles, a former assistant U.S. attorney in the Southern District of New York.

The potential of embarrassment of what Individual A might say, if prosecutors were to call him, hung over Hastert. For prosecutors, there was the risk that the witness—who prosecutors said struck a deal to receive millions of dollars from Hastert—might appear less than credible to a jury.

“There are many different factors that go into this,” said Zimiles, who is now head of the global investigations and compliance practice at Navigant Consulting. “This is a gamble for both sides.”

Hastert is the longest serving Republican speaker of the U.S. House, serving from January 1999 until Republicans lost the House in the 2006 elections.

He was often referred to as the “accidental speaker” for his unusual rise to power following the resignation of former Rep. Bob Livingston, R-La., who was set to succeed Newt Gingrich in the post but bowed out after revelations of extramarital relations.

Follow USA TODAY Chicago correspondent Aamer Madhani on Twitter: @AamerISmad