Then-U.S. attorney and Republican Senate candidate Matthew G. Whitaker at a debate in Johnston, Iowa, in 2014. (Charlie Neibergall/AP)

Iowa state Sen. Matt McCoy believed he was on a path to running for governor or Congress when FBI agents knocked on his door one morning in 2007. He soon learned that he was facing prosecution by a U.S. attorney for the Southern District of Iowa named Matthew G. Whitaker.

The case has now become another focus of controversy for Whitaker, who President Trump named Wednesday as acting attorney general.

McCoy said in an interview Friday that he thought that Whitaker, a conservative Republican, targeted him because he is an openly gay Democrat, a charge that Whitaker’s spokesman denied.

Whitaker, who served as U.S. attorney from 2004 to 2009, announced the case against McCoy with much fanfare, alleging that the senator had used his office to extort about $2,000 from a local company that installed motion sensors in the homes of senior citizens to monitor their health. Prosecutors alleged that McCoy leveraged his position as a senator to demand a $100 commission on each unit.

The case was controversial from the start, in part because McCoy’s attorney accused prosecutors of misconduct for failing to reveal that an informant had been paid. The judge declined McCoy’s request to dismiss the case, but he did grant a continuance that enabled McCoy to find more witnesses, according to McCoy’s attorney, Montgomery Brown.

In the end, the case fell apart. McCoy said he was involved in a normal business deal, and a jury agreed, acquitting him after two hours of deliberation.

The case set off a firestorm in the local media. Rekha Basu of the Des Moines Register wrote a blistering column at the time that said Whitaker’s case “was based on the word of a man former associates depicted as a drug user, a deadbeat and an abuser of women; a man so shady even his Alcoholics Anonymous sponsors called him a ‘pathological liar.’ ” Basu noted that McCoy is a gay Democrat, while Whitaker is a Republican who “has ties to the evangelical Christian community.”

McCoy, in a Friday interview with The Washington Post, said the case cost him $100,000 in legal expenses and upended his life.

“I was a rising star in the party, and people believed that I had a future to run for governor or Congress,” McCoy said. “I don’t think he liked gay people, and I was an outspoken Democrat,” he said, when asked why he thought Whitaker brought the case.

A Justice Department spokesman, who was not authorized to speak on the record, denied that Whitaker targeted McCoy for prosecution.

“Whitaker had a responsibility to uphold the rule of law and pursue credible allegations of illegal activity,” the spokesman said. “The Department of Justice signed off on bringing the case, the FBI conducted an independent investigation, and career prosecutors handled the case throughout its duration. The jury’s verdict does not negate the obligation of law enforcement agencies to open cases when they determine laws may have been broken.”

McCoy went on to be reelected as a state senator and was just elected county commissioner, a position he begins in January.

Julie Tate and Alice Crites contributed to this report.