A correction to an earlier version of this article has been appended to the end of the article.

DANVILLE — Three years after a high school student was accused of showing a video some claimed was racist and insensitive when he ran for student body president, the San Ramon Valley Unified School District has settled a $665,000 lawsuit and will issue him an apology.

Nathaniel Yu, had his student body president title stripped away his junior year in May 2017 when he posted a James Bond-style video on his Twitter account. The video caused a stir within the community and on social media as critics said it depicted armed students as “Muslim terrorists” and was insensitive and lewd. Tensions rose when more than 50 people spoke out about the video during a school board meeting at the time.

After Yu sued, school officials reinstated his student body president title. That action triggered hundreds of students at San Ramon Valley High to walk out of class in protest.

Yu didn’t drop the lawsuit after his title was reinstated, however, claiming district employees retaliated against him and continued to publicly disparage him.

On Tuesday, the district agreed to settle with Yu for $665,000 and apologize on its website within five days for “negative effects, disruption, and emotional distress,” according to Yu’s legal team.

In the apology written by San Ramon Valley Unified School Superintendent Rick Schmitt, and obtained by this news organization, the superintendent states: “We want to formally acknowledge that, despite various reports on social media and in the press that described the video as ‘hate speech,’ we do not believe the contents of the video constituted ‘hate speech.’ ”

Schmitt also wrote that the district believes the video “did not bully, harass, discriminate against or threaten anyone,” or portray any sexual content.

“The District recognizes and regrets the negative consequences associated with mischaracterizations regarding you and the content of the video,” he adds.

That’s in marked contrast to what the district stated in 2017, when in response to Yu’s lawsuit it claimed “The video makes repeated racist and insensitive references to Middle Eastern people, stereotyping them based on their dress, accents and language, names, manner of praying and religious dietary restrictions.”

In his lawsuit, Yu contended his First Amendment rights were violated when the school disciplined him for creating the video. In addition to stripping away his president title, the district removed Yu from a leadership class and disqualified him from running in the associated student body presidential election.

Yu said this is the most successful student speech lawsuit in U.S. history. Yu, now 20 and a college student, told this news organization Tuesday the controversy took a heavy toll on him and his family.

“What happened was completely outside of our imagination,” Yu said. “They blew it way out of proportion… I received death threats. It put my family into hiding, and it was a rough time for us.”

Through all that, Yu said he weathered his senior year at the school amid lies and rumors while continuing to serve his classmates as student body president.

“It’s been a very long fight,” he said. “…I hope it provides a safeguard for students across the country for many more years to come.”

McFall said the district agreed that what happened to his client boiled down to some school officials simply not liking the video.

“Nate shouldn’t have been subjected to that community backlash and false accusations of him,” he said.

Yu’s attorney, James McFall said the school punished Yu for the parody video it described as “offensive” and “inappropriate,” even though the First Amendment prohibits “government officials from punishing speakers for speech simply because they subjectively disapprove of its content.”

The video showed a teen boy playing a video game in his room, with a box of tissues and a bottle of lotion on a desk nearby. In 2017 court documents, school district attorneys referred to the scene as innuendo to the teen performing a sex act.

A screenshot from the video depicted a plastic toy gun and two other teenage boys of Afghan descent kidnapping the boy. The video ends with Yu rescuing the “abducted” boy from the terrorists, with a campaign promise that he will protect his constituents.

School district attorneys, in their 2017 response to the lawsuit, described scenes of torture (slapping the shirtless teen on his stomach), and realistic-looking replica guns. Another scene shows the boys using unattached clamps to “electrocute” the abducted character. A total of about five teenage boys were in the video.

Yu’s lawyer in 2017, First Amendment attorney Gill Sperlein, told this news organization then that the video was a parody gone wrong. He said the video wasn’t intended to make a characterization of the Muslin community as a whole, but only radical Islamic terrorists, “which we can all agree are bad guys,” Sperlein said in 2017.

In November 2019, U.S. District Court Judge Maxine Chesney ruled against the school district’s motion to dismiss the case, rejecting an argument that the parody constituted school-sponsored speech, according to Yu’s attorneys. In December, the district and its legal team were ordered to release more than 12,000 pages of documents that Yu’s attorneys said were previously withheld. A settlement was soon proposed.

San Ramon Valley Unified School District did not immediately respond to a request for comment.

Staff Writer Jon Kawamoto contributed to this story.

Correction: April 8, 2020 An earlier version of this article incorrectly attributed the information that this was the most successful student speech lawsuit in U.S. history to attorney James McFall when it should have been attributed to Nathaniel Yu.