An upstate New York man who wanted to target religious and racial minorities for attacks has been sentenced to three years in prison for illegal possession of a machine gun.

The U.S. Attorney's Office in Albany says 19-year-old Robert Shane Smith of Whitehall in Washington County was sentenced Tuesday as a result of a federal anti-terrorism task force's investigation into Smith's online threats against blacks and Jews.

Prosecutors say Smith admitted he tried repeatedly to buy fully automatic weapons and semi-automatic weapons that he intended to convert to fully automatic. His social media postings included advocating violence against minority groups and "destroying the government."

An FBI sting resulted in his arrest in Whitehall in August 2015, when he acquired machine guns and ammunition from an undercover agent.