A peaceful student demonstration at a Virginia high school ended with school administrators suspending 23 teens for wearing clothing emblazoned with the Confederate battle flag, which violates the school’s dress code, according to school officials, students and parents.

The students, who attend Christiansburg High School in southwestern Virginia, said  they wore the controversial Confederate symbols to protest a school policy that prohibits them, which they view as a violation of their free speech. Students are barred from wearing any clothing that could “reflect adversely on persons due to race” and specifies that “clothing with Confederate flag symbols” falls in that category.

Brenda Drake, a spokeswoman for the Montgomery County, Va., schools, said half of all middle schools and high schools in the county do not allow the display of the Confederate battle flag. About 8 percent of Christiansburg High School’s 1,100 students are black, and more than 80 percent are white, according to the Associated Press.

Drake said Confederate flag symbols have been banned at Christiansburg High since 2002, following a year in which the campus was roiled by racially charged fights, some of which were linked to students’ wearing Confederate symbols.

“It was an entire school year of significant racial tension,” Drake said, adding that some of that violence has continued despite the ban. “I think, certainly, we value First Amendment rights, but we have to maintain an orderly and safe environment for all students.”

Christiansburg junior Zach Comer was among the students who took part in the parking lot rally Thursday morning. He said the purpose of the demonstration was to criticize the school’s dress code, which he said unfairly targets the Confederate battle flag and those who fly it.

“We’re not trying to go into school and raise Cain or anything,” Comer said. “We’re doing it to raise a point that the flag is not racist. Everyone else can wear whatever shirts they want, but we’re not. We just said, ‘It’s time to put a stop to it.’ ”

Comer appeared at the rally with a Confederate flag draped over his shoulders. He also wore a Confederate flag belt buckle and a T-shirt with a “big Rebel flag on the back,” he said, inscribed with the message: “It’s a lifestyle, y’all wouldn’t understand.” He opted against wearing his Confederate flag cowboy boots, he said, because “I didn’t want it to be too much.”

Comer said that he does not discriminate against anyone, regardless of sexual orientation or skin color.

“Live life like you want to live life,” Comer said. “But people are trying to stop me for living mine. I’m just tired of it.”

The Confederate battle flag has long been controversial, with some arguing that it is a proud symbol of Southern heritage and others protesting that it is a symbol of hatred that glorifies slavery and bigotry. The Confederate flag and monuments to Confederate leaders have come under increased scrutiny in recent months, after a white man went on a shooting rampage at a black Methodist church in Charleston, S.C., in June. Dylann Roof, 21, posed in photographs with the Confederate flag before the shootings.

In July, legislators in South Carolina voted to remove a Confederate flag that had flown on the State House grounds for decades, and colleges across the country have been reexamining their display of flags, monuments and icons that nod to the Confederacy and its leaders.

Chet Morley, 18, graduated from Christiansburg High this year and is now attending the Berklee School of Music in Boston. Morley said he saw students wear belt buckles or T-shirts with the Confederate battle flag during his time at the high school. Some teachers sometimes pointed out that it was against the dress code, but others overlooked it.

Morley, who is black, said seeing the flag bothered him, but he never piped up around his white classmates who donned it. While his classmates said the flag symbolized their pride in their Confederate roots, Morley said it made him think of slavery. His stepfather is a descendant of a slave, and his father’s family, from the Bahamas, likely has slave roots as well.

“Southern pride is just a little coverup, if you ask me,” Morley said. Referring to the Confederate battle flag, he said: “As for me and my ancestors, it means more than that.”

Comer said the confrontation between the students and school administrators Thursday morning transpired as the students walked toward the school’s doors for the first classes of the day. They were stopped by school leaders who told them that they were not allowed inside wearing the Confederate regalia.

“We said no,” said sophomore Dalton Reedy, a member of the Sons of the Confederacy, who wore a T-shirt with the Confederate battle flag as well as a belt buckle, bandanna and necklace. “It’s my heritage. I grew up on it. It has nothing to do with racism.”

Reedy, who said his ancestors fought for the Confederacy in the First Battle of Bull Run, said he doesn’t believe the dress code policy is fair. “Most people look at me like I’m a racist. What I really find offensive is we have a black student awareness club, but we don’t have a Mexican awareness or Russian or white club.”

Reedy’s mother, Angie Craiger, said she was proud of her son for “standing up for what he believes in.”

“He’s not one of these people to sit back and complain about it at home and do nothing to make a difference,” Craiger said. “Why are they trying to begrudge him for his beliefs?”

Comer said students plan to continue the protest when they return to school Friday by wearing their Confederate flag clothing again.

“We definitely got a point through today,” Comer said. “We set out to accomplish something today, and we way overachieved it.”