When a former classmate at Central Bucks High School West was accused of hate speech after calling a Black teen a slur, Andrew Smith took to Snapchat to defend him.

“This is America, and u can speak your mind as long as it’s not a threat to someone else’s life, and the ‘hate crime’ was hypothetical and not directed at her,” Smith, 19, wrote last week on the social media site, according to court documents.

He didn’t take his own advice, according to prosecutors. Hours later, Smith posted again, railing against the teen, after mutual acquaintances criticized his first response.

“Like, I can show you what a real hate crime is,” Smith said in the video. “Like, I’ve got a gun, do you want me to?”

Smith, of Chalfont, was charged late Friday with terroristic threats and harassment, court documents show. He remained in custody Monday at the county jail, in lieu of $200,000 bail.

Bucks County District Attorney Matthew Weintraub said his office wanted to be deliberate in its investigation after learning of the alleged threat last week.

“I’ve continued to personally keep the victim’s family informed throughout this investigation,” he said. “We’ve been committed to seeking justice in this case from the very beginning. Hopefully, Mr. Smith’s arrest will give the family some peace of mind.”

There was no indication Monday that Smith had hired an attorney. Smith’s parents did not respond to a message left at their home.

In an interview with police on Thursday, Smith admitted he had made the posts on Snapchat and said he does not own any firearms, according to the affidavit of probable cause for his arrest.

“He said he made the posts because he was angry that [the victim’s family] was trying to ruin the life of the original poster,” the affidavit said.

The post at the center of this dispute, made by another teen who does not face charges, called the victim by the N-word, derided her for her support of the Black Lives Matter movement, and said her political views “make me wanna commit a black hate crime.”

After Smith’s initial post defending the use of the slur against the teen, a friend of hers “called Smith out for his racist post,” the affidavit said.

In response, Smith mocked the girl’s friend, who is also Black, telling him he is “literally the whitest black person ever,” according to court documents.

In a statement, Central Bucks School District Superintendent John J. Kopicki said he and his staff were “incredibly disheartened” by the incident and that the district “condemns all forms of violence, inequity, and racism.”

“We are actively investigating this situation and taking appropriate steps to ensure equity for all students and for the betterment of our community,” Kopicki said. “Central Bucks is committed to creating a community where everyone may feel safe to be exactly as they are by cultivating a culture of respect that allows us to learn and grow together through challenging circumstances.”