The mood was buoyant Wednesday night, as a small group of high school students gathered with friends to share a meal and conversation. Handshakes and hugs passed as greetings at the door, and when everyone had settled, one student pulled a long piece of cloth from her belongings.

She handed it to her senior schoolmate Fillipi Gomes, who smoothed out the length of green fabric covered with circles of blue and spots of yellow, and flung it around his shoulders. It was the first time that Mr. Gomes had laid eyes on the scarf that has, in his last few weeks of high school, caused an unexpected uproar in this small community.

The petition began quietly, several months ago, when some 10 students submitted a written request to wear scarves in the color of the Brazilian flag over their gowns at this year’s graduation ceremony. School principal Stephen Nixon denied the request, citing a school policy that barred students from wearing personal items. But on Monday, the regional high school district committee overturned Mr. Nixon’s decision, voting to allow students to wear personalized scarves without penalty.

“I had already given up on this year,” said Mr. Gomes. He said he was hoping that future students would have more luck, when he heard about the last-minute reversal.

“This is it,” said Mr. Gomes Wednesday, showing off his scarf. It could be nicer, he said. More ornate, and more expensive. But those qualities could not make the garment any more meaningful. The small group gathered in the room agreed: this simple scarf will be treasured for years to come, the symbol of of a small group of students and their courage to stand up for themselves in the face of adversity.

When the school principal formally denied the request, Mr. Gomes and his classmate and cousin Andora Aquino, both native Brazilians who immigrated to the United States as small children, shared the story with the Gazette. It was later picked up by the Martha’s Vineyard Times, another weekly newspaper on the Island. Suddenly the issue erupted into an online war of words, exposing deep-seated resentment against the Island’s Brazilian community.

“It was brought from us just trying to wear scarves, to show our pride and nationality, to a big thing on race,” said Mr. Gomes.

“I am sooo fed up with all these Brazilians trying to take over,” wrote one reader on the Martha’s Vineyard Times Web site, identified only as Kol. “Everywhere they go, they take the work, free health care, when we are penalized by the IRS if we are not covered,” the reader wrote.

“If the Brazilians want to wear their colors, send them back to Brazil where nobody gives a damn what they wear,” wrote a commentor named Bob on the Gazette Web site.

Others were more supportive. “Show your pride, wear your colors, be who you are. This is your day students, and no one can take it away from you,” wrote Arthur Hardy-Doubleday, of Oak Bluffs and Beacon Hill, on the Gazette Web site.

“Everything happened and there were two sides formed right away,” said Mr. Gomes on Wednesday night. “And that’s not what I was trying to get to in any way, that’s just the way it happened.”

Ms. Aquino, who was also at the gathering, said she was stunned at the reaction. Suddenly, being Brazilian became synonymous with being an illegal immigrant, and Ms. Aquino, who is a top student at the high school and headed to Colgate University in the fall, said she felt unfairly targeted.

“The girls kind of took it to heart,” said Mr. Gomes, referring to Ms. Aquino and the other female students who signed the petition. “It doesn’t affect me as much, because I don’t take it so seriously. Because I know it’s always out there. No matter where you go there’s always going to be racism,” he added.

Still, he worries that for some Brazilian-American students, fear will trump pride at graduation.

“I’ll be there with my scarf on,” Mr. Gomes said. “I hope I’m not the only one up there anymore. Because now a lot of people are scared. Intimidated to wear them. Not because they’re not proud, but because of the comments people say and the hate factor . . . They’re scared they’re going to be picked on now, not by the student body, but by outside people in the community.”

And that is another twist in this controversy. Mr. Gomes said the Brazilian students have seen no backlash from fellow students, only from adults, most of them anonymous online writers. “The student body doesn’t really mind it because it doesn’t affect them. It doesn’t hurt them. It doesn’t bother them,” he said.

And the high school senior also firmly took the high road, saying that he understands those who didn’t support him. “I kind of want to get it out there that I personally don’t have a grudge. I know that they’re following the rules, Mr. Nixon and Mr. Weiss,” he said.

But the committee vote changed those rules Monday night, and now, less than a week before graduation, the students can begin to get excited about their victory — and their high school graduation.

“I’m proud of what I am,” said Mr. Gomes, adding that the scarves will be meaningful to more than just the students. “Our families are there too. I know my mom would be happy to see me representing my nationality.”

He concluded: “It’s not just for us. It’s not just for the Brazilians. Now everyone can do it, because we went out of our way to try to get something done. And now we did.”