Ben Ellis, who taught Latin and Bible studies at Christ Presbyterian Academy in Nashville, died Friday, said Nate Morrow, the school's headmaster.
A few days ago, 400 students from the school showed up outside his home to sing songs of worship when he could no longer teach.
Despite chemotherapy and radiation treatments, Ellis taught until earlier this month because the distraction helped him through it.
Last week, he was having a tough morning after receiving bad news about his treatment options, according to Morrow.
"The high school principal said, 'Ben has loved us well. Stop what you're doing, load up the buses. We're going to his house to worship with him,'" Morrow said.
In a video posted by musician Tim McGraw, the teacher is seen singing along to "Holy Spirit You are Welcome Here" with the students gathered outside his window.
"A friend sent this to me today," McGraw wrote. "The entire student body (400+ students plus HS faculty) drove to his house to worship with him."
'Full of hope, peace'
The video has been viewed 31 million times since it was posted, and Ellis' friends and family have been posting their stories in the comments.
"Ben is my son," Bob Ellis wrote. "Through his ministry and teaching, he has positively touched countless hundreds of lives directly and many thousands indirectly. He, his wife and children are a beautiful family."
Morrow said his death affected them all.
"He left these words for us, spoken over the students at his house, and I share them with you to guide us now," Morrow said.
"He said, 'I love you. I believe now more than ever that God is good, and that He is with us. I am full of hope, peace and joy. I wish all this for you. Look to Jesus to know, to believe, and to be filled.'"
Ellis leaves behind a wife and five children.