Four years after federal agents showed up at his Frederick, Md., farmhouse and told him that they had seized the money in his bank account, dairy farmer Randy Sowers has gotten it all back.

The victory followed political pressure from Congress and legal pressure from the libertarian Institute for Justice on the government to roll back prosecution of the crime of structuring bank deposits to avoid Internal Revenue Service reporting requirements.

“I’m happy in more ways than one,” Sowers said after the announcement. “Getting my money back and defeating something that was wrong.”

When someone puts more than $10,000 in the bank at once, the bank makes a report to the IRS. Putting less than that amount in an account so as to intentionally avoid the scrutiny is a crime. In hundreds of cases, the Justice Department has seized money from the accounts of people accused of structuring.

The thing that is wrong, in the view of Sowers and his supporters, is going after people who are guilty of nothing other than trying to avoid the IRS report. He maintains that a bank teller told him it would be easier for everyone to keep deposits down and avoid the reporting requirement; he says that if anyone should have been prosecuted, it’s the teller.

Locals and tourists can get fresh food and dairy products at the South Mountain Creamery store. Ice cream is the best seller. (Michael S. Williamson/The Washington Post)

“I guess the way the law was set up, we broke it,” Sowers said, “but we had no idea.”

So he fought back. He testified before a congressional committee and appeared on television broadcasts aired as far away as China. As he sought support locally, it helped that his farm, South Mountain Creamery, is popular across the D.C. and Baltimore regions for its home-delivered milk and annual farm festival.

[Uncle Sam may have picked the wrong cash cow]

In October 2014, the IRS changed its policy to say it would pursue seizure of structured assets that came only from criminal activity. In March of last year, the Justice Department announced it would follow suit.

By that time, Sowers, hesitant about getting mired in a long court battle, had already agreed to a deal under which the government took 10 percent of the $295,220 he was accused of structuring. After the change in policy last year, he filed a petition to get his money back.

“I mean, I could use the $29,000 right now for sure,” he told a congressional committee this May.

Another Maryland farmer, Calvin Taylor of the Eastern Shore, testified at the same House Ways and Means subcommittee hearing. He said that when his funds were seized in 2011, the IRS agents who came to his home told him they did not think he had knowingly done anything wrong. But like Sowers, he said he chose to give up $41,000 rather than wage a legal battle he had little chance of winning. He has also petitioned for a refund.

On Wednesday, Sowers and his attorneys got word that the petition had been granted. He’s the first person who settled with the IRS to get his money back.

“This is just an in­cred­ibly exciting development for Randy but also for everybody else who’s had money taken under the structuring law,” said Robert Johnson, the Institute for Justice attorney who filed Sowers’s petition. “When we started out down this road, nobody would have thought we would get to this point.”

The petitioners say the congressional hearing helped pressure the Justice Department. A bipartisan group of lawmakers pushed a Justice Department representative to move on Sowers’s behalf.

“You have the authority to fix this, and you have the authority to do something extraordinarily great here,” Rep. Peter J. Roskam (R-Ill.) said at the hearing.

The lawmakers also questioned what the IRS is doing to help people whose assets were seized; in response, the agency has sent out letters in 700 cases notifying subjects that they can petition the Justice Department for a return of their funds.

“We think that last hearing probably lit the fire under them to act on Randy’s petition,” said Paul Kamenar, who worked with the Institute for Justice on Sowers’s case. “We are trailblazers in making the way for the other American citizens whose funds were seized in an unjust matter to also get restitution.”

The assistant U.S. attorney who prosecuted Sowers, Stefan Cassella, now works as a private asset forfeiture consultant. He does not think the government did anything wrong.

“I thought that we treated him extremely fairly,” Cassella said. “We gave him an enormous break.”

Sowers doesn’t have a grand plan for his returned cash; he says he will use it to pay farm bills.

“What I want to do,” he said, is “sell milk to people — real milk.”