(Reuters) - An avowed white supremacist and supporter of the gunman behind the massacre at an African-American church in South Carolina in 2015 was sentenced to nearly three years in prison on Wednesday for illegally buying a gun from an undercover FBI agent.

Benjamin McDowell, 31, a convicted felon who was barred from owning a gun, received the maximum penalty from a U.S. District Court judge in South Carolina.

The FBI learned of McDowell’s “escalating white supremacist views on social media,” where he expressed admiration for Dylann Roof, who killed nine people in June 2015 in a shooting at a historic African-American church in Charleston, the Justice Department said in a statement.

McDowell, of Conway, South Carolina, about 100 miles north of Charleston, had established connections with a hate group known as White Supremacy Extremists during previous stints in prison, the Justice Department said.

He made comments that suggested carrying out an attack on a particular synagogue, the Justice Department said. An affidavit filed when McDowell was charged identified the house of worship as the Temple Emmanu-El in Myrtle Beach, South Carolina.

McDowell told an undercover FBI agent who was posing as a member of a white supremacist organization in 2017 about his desire to commit acts of violence against Jewish and Muslim people, the Justice Department statement said. He did not reveal a specific plan against a particular location or victim.

An FBI agent then met McDowell to sell a gun that had been made inoperative, as well as ammunition. Shortly afterward, McDowell was arrested in the parking lot of a hotel in Myrtle Beach, the Justice Department said.

McDowell pleaded guilty. After he leaves prison, he will undergo three years of supervised release, the Justice Department said.

Bill Nettles, McDowell’s lawyer, said in an email that the sentence reflected his client’s prior criminal history and other aggravating factors.