Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

BOYNTON BEACH, Fla. — On the night his students debated National Rifle Association spokeswoman Dana Loesch at a nationally televised town hall, Jeff Foster sat off to the side of the stage like a boxing coach watching his prizefighters.

Thinking back on that experience from the kitchen counter of his Boynton Beach home on Monday, Foster, 46, the fast-talking, tell-it-like-it-is AP government teacher at Marjory Stoneman Douglas High School in nearby Parkland, is almost at a loss for words.

“To see that happen and realize that’s someone that’s in your class, it’s pretty crazy,” Foster told NBC News. “It’s almost like an out-of-body experience.”

Foster said former students have gone on to become elected officials or leaders in their fields, but to watch senior Emma González take on Loesch using lessons he taught was something different.

Before she asked her question, González took a moment to thank Foster. Then she turned to Loesch.

“The shooter at our school obtained weapons he used on us legally. Do you believe that it should be harder to obtain semiautomatic weapons and the modifications for these weapons to make them fully automatic, like bump stocks?” González asked.

As Loesch discussed the NRA’s position and González interjected her original question, Foster watched the back-and-forth with pride.

“I went up to her on every commercial to kind of talk to her cause I was right in front of the stage. I kind of huddled with all of [the students] just to be like, ‘You guys are doing great,’” Foster said. “And just to see the kids and the adults who were coming to the stage to tell her ‘thank you’ ... it was pretty amazing.”

Nearly all the Stoneman Douglas students who have become familiar faces advocating for gun reform since a gunman killed 17 people there on Valentine’s Day have come from Foster’s AP United States Government and Politics class. And on that day, Foster learned just recently, some of the survivors initially mistook the sound of real gunfire for an active-shooter drill they had been told to expect.

Family members embrace following a shooting at Marjory Stoneman Douglas High School on Feb. 14, 2018 in Parkland, Fla. Wilfredo Lee / AP file

Over the last month, Foster has adopted new roles, including helping his students and colleagues plan the March for Our Lives in Washington on March 24. He’s also absorbed some of the responsibilities of Scott Beigel, his friend and fellow teacher at Stoneman Douglas who was killed in the shooting.

It’s a résumé Foster never imagined taking on when he was hired at the school almost 20 years ago.

‘I haven’t regretted a minute of it.’

Foster never anticipated teaching AP government — let alone being the educator behind a fleet of vocal gun reform activists — when Stoneman Douglas hired him in 1999.

When he was asked to take on the course a year and a half after his hiring, he said, he balked.

“I thought this was going to be a lot of work. And then I thought to myself, ‘Wait a minute. This is something you really enjoy and these are great kids and you can really have some leeway with the curriculum,’” Foster said. “Obviously, I said yes, and I haven’t regretted a minute of it.”

Since taking on the role, Foster has taught hundreds of students about special interest groups, with an emphasis on the NRA.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

“It’s such an easy one to explain because of all the things that have happened in this country,” he said of the back-and-forth between politicians and the NRA following school shootings.

A student heads back to school at Marjory Stoneman Douglas High School on Feb. 28, 2018 in Parkland, Fla. Mike Stocker / South Florida Sun-Sentinel via AP

But Foster said he’s open with his students about his own political affiliation.

He texted González one day after the shooting. “So I said, ‘Emma, this is Mr. Foster. If you don’t believe it, I’m the Republican who supports gay marriage and LGBT rights,’” he said.

Foster’s openness with his students has allowed him to develop a close-knit bond with them. When he couldn’t persuade his wife and daughters to see “The Hunger Games” films with him, he ended up in a movie theater for one showing with about 100 of his AP government students.

Shared extracurricular activities like these make the students more willing to learn, he believes. “I think they trust you more and they’re going to try for you more,” Foster said of his relationship with his students.

Students sing his praises. "I've been in his class since Day 1. He's a great teacher. All of us love him," said Justin Hing, 18, a senior. "He's always caring for us, like saying he would take a bullet for us cause that's how much he loves us."

Now, instead of movie night, Foster and his students spend every free second planning marches and writing speeches so a massacre like the one on Feb. 14 never happens again.

The day everything changed

The morning of Valentine’s Day started the same as most in the Foster household. Foster woke up around 5 a.m., got his 11-year-old and 6-year-old daughters out of bed and made their lunches.

Before heading to work, Foster surprised his wife, Loren, with Justin Timberlake tickets.

At Stoneman Douglas, a second-period fire drill went as planned. Foster said administrators had stressed new techniques to use during the drill, which was the second or third in two weeks. The fuss surrounding the drill spurred Foster to tell students that another one would be coming soon — a code-red drill to be used in case of an active gunman.

“I said, ‘Guys, we’re going to have one of these drills soon. There might be fake bullets and there might be this and there might be that,’” Foster said.

Last week, as Foster and his students tried to remember the timeline of events, they reminded him that he had mentioned code-red drills on the day of the shooting.

"And so those kids told me on Friday that when the fire drill went off and they heard the bullets, they thought it was fake because I had told them we were going to have a live drill.”

During the last hour of the day, Foster was wrapping up a lecture on special interest groups, which included discussing the NRA, when the fire alarm when off.

Foster shepherded his students to their designated exit area. As the group got close to its exit point, one teacher with Foster heard gunshots.

Moments later, Foster’s phone rang.

“My brother calls me and says, ‘You have an active shooter on campus,’” Foster said.

Eventually, after the students had been evacuated, Foster and two colleagues made it to a nearby restaurant, where they received call after call about who was or wasn’t dead. Rumors began to circulate that Scott Beigel, Foster’s friend and colleague, had been killed. Foster later found out that one of his students, Carmen Schentrup, had also died.

When he finally got home at 9 that night, he collapsed into bed.

Wearing Douglas every day

Since the shooting, Foster has had trouble sleeping. Recently, he began waking up in pools of sweat after dreams about students and colleagues who died.

He attended about seven funerals. He’s also taken on a freshman geography class once taught by Beigel.

“I don’t want to say as far as dreading it, but I don’t look forward to that class. But today I did,” Foster said. Monday was the first day since the shooting that the class has done any schoolwork.

Foster’s openness with his students has allowed him to develop a close-knit bond with them. Josh Ritchie / for NBC News

When Foster goes to school these days, he’s decked out in Marjory Stoneman Douglas High School gear. A black shirt embroidered with the Stoneman Douglas eagle drapes over his slender frame. He wears three Stoneman Douglas bracelets around his left wrist.

“I wear a lot of Florida State stuff to school, but now it’s just been Douglas every day,” he said.

Foster says he knows that the school will be in history textbooks of the future “for the wrong reasons.”

“There’s going to be a teacher teaching next year — and hell, it might even be me, depending on what happens this year — talking about the NRA and how they stopped things,” Foster said. “They’re going to talk about the Douglas shooting and talk about the kids marching and then they’re going to say — and I hope they’re not going to say this — nothing got done.”

But Foster acknowledges his role in moving the needle in Florida, where last week Gov. Rick Scott signed the Marjory Stoneman Douglas High School Public Safety Act, which raises the age to buy all firearms to 21, imposes a three-day waiting period for most gun purchases, allows trained school workers to carry handguns, provides new mental health programs for schools, and restricts gun access to people who show signs of mental illness or violence.

Although he gave his students the knowledge to take on the gun lobby and state Legislature, Foster deflects the credit.

“It was definitely an organic movement for them to come together and organize, and I wasn’t in the room when that happened,” Foster said. “It’s nice they’re all giving me credit ... but I mean it’s the ultimate grass-roots movement.”

Amid the planning for marches and preparing for the AP exam in May, Foster worries about what happens to the students he’s educated when the cameras go home and graduation rolls around.

“I think the outpouring from the country and the world has been amazing and we’re indebted,” he said. But “when the music stops, I hope they’re going to be OK.”