President Trump on Thursday pardoned conservative filmmaker Dinesh D’Souza, who was convicted of making an illegal campaign contribution in 2014.

"Today, President Donald J. Trump issued an Executive Grant of Clemency (Full Pardon) to Dinesh D’Souza, an accomplished author, lecturer, and scholar," said a statement from White House Press Secretary Sarah Sanders. "Mr. D’Souza was, in the President’s opinion, a victim of selective prosecution for violations of campaign finance laws. Mr. D’Souza accepted responsibility for his actions, and also completed community service by teaching English to citizens and immigrants seeking citizenship."

She added: "In light of these facts, the President has determined that Mr. D’Souza is fully worthy of this pardon."

Earlier in the day, Trump tweeted: “Will be giving a Full Pardon to Dinesh D’Souza today. He was treated very unfairly by our government!”

D'Souza told Fox News he received a call from the president on Wednesday to notify him of the decision.

"I am thrilled and relieved and elated and as an immigrant in America, my American dream has been under something of a cloud, so I'm very relieved to have that cloud lifted," D'Souza told Fox News on Thursday.

D'Souza said he and Trump spoke for about 10 minutes, calling it a "very pleasant and very exciting call."

"President Trump told me he felt I had been treated very unfairly and he felt that I was an important voice for America," D'Souza said. "He wanted to clean my record and adhere to continue doing what I'm doing."

D'Souza tweeted later Thursday that "Obama & his stooges tried to extinguish my American dream," while thanking Trump.

The conservative filmmaker had pleaded guilty in 2014 for donating $20,000 to New York politician Wendy Long, allegedly going over the contribution limit by directing other donors to give to her. He was sentenced to five years of probation and eight months in a halfway house, and paid a $30,000 fine.

Despite his guilty plea, D’Souza and his allies have claimed for years that he was unfairly singled out for prosecution, and unfairly treated by the Obama administration.

D'Souza in 2012 made a hit anti-Obama documentary called “2016: Obama’s America.” The film examined then-President Obama’s past and early influences that may have shaped his political ideology.

D’Souza’s 2014 indictment was announced by then-U.S. Attorney Preet Bharara, who was appointed by Obama and fired in 2017 by Trump. The indictment stated that D’Souza was charged with one count of illegally donating to a Senate campaign and one count of causing false statements to be made to authorities in connection with the contributions.

D’Souza’s illegal campaign contribution was made in 2012 to Long’s U.S. Senate campaign. D’Souza pleaded guilty to using a “straw donor” to make the donation.

A straw donor is a person who illegally uses another person’s finances to make a political contribution in their own name. Straw donor schemes are illegal under U.S. law, which states that no person should knowingly permit their name to be used to “effect such a contribution” and no person “shall knowingly accept” a contribution made by “one person in the name of another person.”

D’Souza allegedly coordinated donations to Long’s campaign through friends and acquaintances. Long lost her Senate bid against now-Sen. Kirsten Gillibrand, D-N.Y.

Fox News’ Judson Berger contributed to this report.