BOISE, Idaho — Former U.S. Sen. Larry Craig has been ordered to pay nearly $242,000 to the U.S. Treasury for improperly using campaign funds to cover legal expenses after his arrest in a 2007 airport bathroom sex sting in the Twin Cities.

U.S. District Judge Amy Berman Jackson ruled Tuesday that Craig illegally converted campaign money for personal expenses while trying to withdraw his guilty plea to one count of disorderly conduct. The order says Craig must pay back $197,535 of campaign funds plus a penalty of $45,000.

Jackson found that Craig violated the Federal Election Campaign Act by converting campaign funds for personal legal expenses.

Craig’s effort to withdraw his guilty plea “was a personal matter that was not connected to the senator’s duties as an officeholder,” Jackson wrote.

Jackson also noted that her judgment was the first of its kind, adding that no other court has been asked to determine what the punishment should be for not following the particular section of the campaign law Craig violated.

The Idaho Republican had argued that Senate rules allow reimbursements for any official travel costs and that he was traveling between Idaho and Washington, D.C., for work. Messages seeking comment were left for his two lawyers Tuesday.

Craig was arrested June 11, 2007, by an undercover police officer at the Minneapolis-St. Paul International Airport. The officer said Craig tapped his foot and signaled under the stall that he wanted sex.

The senator pleaded guilty to disturbing the peace but immediately began a prolonged fight to undo his plea using campaign money.

The Federal Election Commission had wanted Craig to pay $140,000 in fines and return nearly $217,000 to his campaign.