SYDNEY, Australia — A 9-year-old Australian schoolgirl whose refusal to stand for the singing of the national anthem has stirred a nationwide debate said Thursday that she would continue to protest the song she said was racist even if it meant being kicked out of school.

The girl, Harper Nielsen, was sent to detention and threatened with suspension from her Brisbane primary school last week after sitting through a schoolwide rendition of “Advance Australia Fair,” the national anthem, she said.

News of her protest quickly went viral, leading to condemnations by conservative politicians and a national conversation about race and free speech.

The girl’s protest, which echoed those of American football players who have knelt at games during the playing of “The Star-Spangled Banner,” made headlines in the same week that a national newspaper printed a cartoon depicting the tennis player Serena Williams with exaggerated lips.