FLORENCE, S.C. — A white supremacist faces up to 10 years in prison for illegally buying a gun authorities say he planned to use in a hate crime attack similar to the South Carolina church shootings.

Benjamin McDowell, 30, pleaded guilty Monday to being a felon in possession of a weapon, according to reports by multiple news outlets. He also could be fined $250,000 when he’s sentenced at a later date.

Authorities first began investigating McDowell in December 2016 when he threatened a Myrtle Beach synagogue on Facebook. Local officials were already keeping tabs on him because he made friends with white supremacist groups and got tattoos associated with racist groups while in prison on a felony burglary charge, according to the FBI.

McDowell then said he wanted a gun and told an undercover FBI agent who offered to get him one that he planned to attack somewhere in the name of white power and write on the building “in the spirit of Dylann Roof,” according to court records. Roof was sentenced to death last year for a racist shooting that killed nine black worshippers at a Charleston, South Carolina, church.

“I seen what Dylann Roof did and in my heart I reckon I got a little bit of hatred,” the undercover agent recalled McDowell saying.

McDowell, who couldn’t legally own a gun because of the burglary conviction, was arrested after the purchase. Agents said McDowell bought the gun — which had the firing pin shaved down so that it would not work — and ammunition for $109, which he had borrowed from his grandfather.