NEW YORK (Reuters) – Conservative author and filmmaker Dinesh D’Souza pleaded guilty on Tuesday to a campaign finance law violation, avoiding a trial that had been expected to begin the same day in a Manhattan federal court.

D’Souza, known for his biting criticism of President Barack Obama, pleaded guilty to one criminal count of making illegal contributions in the names of others. A second count concerning the making of false statements is expected to be dismissed once he is sentenced.

The plea came four months after Manhattan U.S. Attorney Preet Bharara charged D’Souza with using “straw donors” to give funds in 2012 to Republican Wendy Long’s U.S. Senate campaign in New York. Long, who met D’Souza while they were students in the 1980s, lost to Democratic incumbent Kirsten Gillibrand.

“I knew that causing a campaign contribution to be made in the name of another was wrong and something the law forbids,” D’Souza, 53, told U.S. District Judge Berman on Tuesday. “I deeply regret my conduct.”

Prosecutors said D’Souza asked two friends and their spouses to contribute $10,000 each to Long’s campaign and then reimbursed them. At the time, campaign finance regulations limited individual donations to a maximum of $5,000 during an election cycle.

One of the friends was Denise Joseph, who was engaged to D’Souza while he was still married to another woman. D’Souza resigned as president of King’s College, a small Christian school in New York City, after the media revealed his relationship with Joseph in 2012.

The criminal case against D’Souza prompted an outcry among some conservatives who accused the government of selectively prosecuting him because of his political views.

The Indian-born D’Souza wrote the 2010 bestseller “The Roots of Obama’s Rage” and co-directed a 2012 film, “2016: Obama’s America,” which painted a bleak picture of the nation’s future if the Democratic president was reelected.

Bharara is an Obama appointee.

Earlier this year, four Republican senators asked FBI Director James Comey to explain how investigators came to focus on D’Souza. The Washington Times, a right-leaning newspaper, on Monday published an editorial accusing the Justice Department of selective prosecution.

In a previous court filing, D’Souza’s lawyer, Benjamin Brafman, said his client was singled out for his criticism of Obama.

Berman, however, ruled D’Souza was not entitled to seek government evidence that could have bolstered that argument, saying there was no sign D’Souza had been targeted.

Lawyers for both sides agreed that under advisory federal sentencing guidelines, D’Souza faces between 10 and 16 months in prison. Brafman, however, indicated he would ask Berman not to impose prison time, telling reporters D’Souza is a “fundamentally honorable man” who had committed an “isolated instance of wrongdoing.”

D’Souza, who was a policy adviser for President Ronald Reagan and has worked with conservative institutions such as the American Enterprise Institute, declined to comment.

The case is U.S. v. D’Souza, U.S. District Court, Southern District of New York, No. 14-cr-00034.