OXON HILL, Md. — In a large room in the Gaylord National Conference Center at the end of March, an epic battle took place. Teams of middle and high school students sat at computer banks around the room, speaking in whispers and staring intently at their screens. Once in a while a teen sprang into action, typing furiously. It may not be much of a spectator sport, but those students were fighting a war.

They were fighting off hackers, who in this case were a team of experts trying to break in to the students’ secure computer network. The students were competing in the national finals for the Air Force Association’s CyberPatriot competition. Out of over 1,500 teams across the country, these 28 school groups made it to the final round.

Officially known as the National Youth Cyber Defense Competition, the contest hopes to inspire students to enter science, technology, engineering and math. “We wanted to get kids excited about STEM,” Bernie Skoch says. He’s a leader of the CyberPatriot program and a Brigadier General in the Air Force. When the Air Force Association was trying to come up with ways to get students interested in STEM fields, he explains, “we thought about contests with rockets and model airplanes. But then, we realized we could attract kids with cybersecurity.” The cybersecurity competition teaches students how to keep computer networks secure from those on the outside, no previous experience required.

“It’s cool stuff,” Skoch says. “There’s not a day you turn on the news that you see someone else got hacked.” Over 3,000 companies in the United States, including big names like Target, had their computers systems hacked in 2013, costing them and their customers up to $100 billion.

Most people don’t realize that every day, their computers are in danger. “There are lots of unsecure things,” says Ian Hurd, a 16-year-old at El Segundo High School in El Segundo, Calif., and a member of the finalist team Net Eagles. “Maybe all the passwords are the same, there are people who are using the computer who are not supposed to be there or programs running that shouldn’t be.”

Hacking into computer systems might seem like the cool thing to do. But the students at CyberPatriot know they are training to be the good guys. “We’re here to stop people from getting hacked, and to stop people from doing bad things,” says Henry Smith, 16, a finalist from El Segundo. “Computers are huge in our lives now so understanding how to keep them safe is important to how we live.”

The students also know that defense is more of a challenge. “These kids know it takes more work to be a defender than to be a bad actor,” says Diane Miller, the program director of CyberPatriot at the competition’s major sponsor, The Northrop Grumman Foundation. “You are always on the watch, you can’t let anything through.”

Any high school group, public, private or homeschooled, can form a team and sign up for the program online. The website gives teachers access to a school years’ worth of materials that will teach them everything they need to know about cybersecurity, from how to write code in different systems to how a virus works. As they learn, teams can compete in their region in virtual competitions, fixing the security gaps in a network for points. The most successful teams advance to the finals, where they compete face to face against professionals.

Each team has a teacher as a coach. William Beckman points out that the students are usually self-starters. “They got themselves into it,” says Beckman, information technologist and coach of a middle school team from the Marine Military Academy in Harlingen, Texas. “My job is just to teach them how to secure computer systems and inspire an interest in the cyber security field.”

But the teachers, just like the students, don’t have to be security experts. Instead, CyberPatriot links teams up with mentors, adults who work in cybersecurity-related fields near their schools. Jennifer Cho, a high school engineering and math teacher at El Segundo, pulled in Ronald Chu, the father of one of the team members and an information technology specialist with the County of Los Angeles, to act as a mentor for their team. “I teach them the ‘how-to,’” Chu says, “it’s more coaching than teaching, the details of how to fix things or set up a secure network.”

Maxime Dowla, 14, said that he learned more than he ever thought he could. “All I knew about computers before what that I could play games on them,” says the middle school finalist from the Marine Military Academy team Leathernecks. “But then I joined CyberPatriot and I liked it, it’s more interesting and will pay off in the long run.” It could also pay off right now. The winners of the competition take home thousands of dollars in scholarships. Some of them will even get internships in cybersecurity.

This year’s trophies went to North Hollywood High School in North Hollywood, Calif., and Clearfield High School in Clearfield, Utah. CyberPatriot also held its first middle school division competition, where the Beach Cities Cadet Squadron from San Pedro, Calif., took home the trophy. For teens who are really excited about computing, registration is already open for next year’s competition.