Two tone-deaf security guards at the 9/11 Memorial got tough with some wide-eyed middle school kids visiting the city for the first time from their small town in North Carolina — because they sang “The Star-Spangled Banner.”

“You have to stop. This is considered a public demonstration!” one guard barked at the patriotic teens, their Waynesville Middle School music teacher, Martha Brown, told The Post.

The guards insisted the group needed a permit to sing, according to Brown.

“Some of the students were very upset and confused. I told the children, ‘This is a place where you need to respect authority even if you don’t understand it,’ ” she said.

The choir was wrapping up a whirlwind field trip to the Big Apple with a somber visit to the 9/11 Memorial on Friday, and had launched into their lilting version of the national anthem when the two guards cut them off.

One mom was so infuriated by the way her kid was treated that she posted footage of the truncated tribute online, where it immediately went viral and now has more than 300,000 views.

“So sad this is happening everywhere. They sounded great. God Bless America!” wrote the mom, Connie Shepherd Scanlon.

Brown had hoped to add some history to their otherwise music-filled itinerary, which included singing at the Cathedral of St. John the Divine and seeing “The Lion King” on Broadway.

The kids were so touched by Ground Zero, they asked to honor the site the best way they knew how, according to Brown.

“Singing was their way of paying respect,” the teacher said. “They were doing it very reverently.”

Brown said she understands the need for rules, but thinks the guard could have handled it better.

“He could have waited 30 to 45 seconds for us to finish, or he could have stopped us before we started, and it wouldn’t have gone viral,” she said.

A memorial spokeswoman admitted that the situation was mishandled.

“The guard did not respond appropriately,” she said. “We are working with our security staff to ensure that this does not happen again with future student performances.”

She did not say whether the security guard was disciplined.