Former Stillwater Mayor Ken Harycki stood before a federal judge in Minneapolis on Thursday morning and admitted he had conspired to defraud the government of millions of dollars in taxes through his payroll accounting business.

Harycki's involvement in concealing state and federal tax liabilities occurred during most of the two terms he served as mayor, although felony charges filed against him by the U.S. attorney's office didn't relate to his elected position.

His guilty plea included a provision that he will provide "substantial" assistance to law enforcement in the investigation and prosecution of other fraud suspects and that he will testify at any trials that result.

In exchange, federal prosecutors will make a motion to U.S. District Judge Ann Montgomery for a reduced sentence, although "no such motion will be made unless the defendant is completely truthful," according to the agreement.

At one point in Thursday's hearing, Montgomery cautioned Harycki to answer questions candidly.

"You could make your bad situation even worse, because then you could be charged with perjury," she said.

Tax losses resulting from Harycki's crimes were estimated at $1 million to $2.5 million.

Criminal charges filed in December said that Harycki, 51, helped a Twin Cities home health care company create shell companies to hide money and that he began working with the men behind the scheme in 2007 — just a year after being elected mayor.

Soon after he was re-elected in 2010, he filed paperwork at his accounting business to incorporate MKH Holdings, Inc., a company intended to defraud the government, according to the charges.

Harycki abruptly resigned his mayor's position on Nov. 7, citing personal problems.

Two brothers linked to Harycki were arrested by federal agents in December and indicted on charges of conspiracy to defraud the government and health care fraud.

Thurlee Belfrey and his brother, Roylee, own and manage several health care businesses with a history of Medicaid fraud and lavish spending, according to court documents. They include Royal Health Care, Model Health Care, Integrated Health Services and an entertainment business, according to court documents and state records.

Federal agents who raided Harycki's accounting office, Customized Payroll Solutions, in March also were looking for evidence of companies named "Beauty Queen" and "MN Finest Swimsuit Calendar," a search warrant showed.

Prosecutors said millions of dollars in federal payments flowed to the companies over 12 years.

Harycki, a certified public accountant, began doing accounting work for the Belfreys and their companies in 2007, and came under IRS investigation in October 2012. Court documents said he prepared falsified tax forms on their behalf.

During the period that he was engaging in criminal activity, Harycki, in his role as mayor, chaired the coalition pushing for a new St. Croix River bridge and attempted to steer $80,000 in city tax revenue to the coalition without a contract specifying how the money would be spent. The state auditor said the donation was illegal because it came from a tax-increment financing fund. The city later lost half of the $80,000 in penalties.

Harycki also lobbied other cities to contribute public funds to promote the bridge but didn't explain how the money was being spent.

In Thursday's hearing, defense attorney Joe Friedberg revealed that Harycki had drained $1 million from his personal retirement account to keep his accounting business afloat. Harycki then falsified tax statements to disguise that income, Friedberg said.

Representing the U.S. attorney's office at the hearing was assistant attorney Robert Lewis, who signed the plea agreement.

The agreement stipulates a prison sentence of three to nearly four years, a fine of up to $30,000, and restitution. However, it doesn't prevent the judge from imposing a different sentence should she choose to do so. No sentencing date has been set.

When a reporter asked Harycki what he wanted to say to the constituents he represented as mayor, he turned his back and walked away.

"As a former mayor, Mr. Harycki understands, better than most, the magnitude and impact of the fraud he helped to perpetrate," U.S. Attorney Andrew Luger said after the hearing. "This defendant not only violated his accounting license by covering up a tax fraud, he eroded the trust of the residents of Stillwater, who elected him to a position of high public office."