LAS VEGAS (Reuters) - A software program dubbed “Mayhem” was poised to win the final round of a three-year contest to teach computers to launch and defend against cyber attacks, earning a $2 million prize for the team that wrote the winning code.

The event, known as the Cyber Grand Challenge, concluded Thursday evening in a Las Vegas convention center ballroom after a digital battle among software programs running on seven supercomputers on a stage in a Las Vegas ballroom.

Thousands watched as announcers presented a play-by-play account of the competition. It took place ahead of Friday’s start of Def Con, a hacking convention expected to draw more than 20,000 people to two sprawling Las Vegas convention centers.

The contest was sponsored by DARPA, or the Defense Advanced Research Projects Agency, the U.S. military laboratory credited with creating the Internet.

DARPA spent $55 million on the effort, which it dubbed the first “capture the flag” hacking contest played solely by computers.

Agency officials said it succeeded in its goal of stimulating development of technologies for automating the process of protecting computer networks against cyber attacks.

DARPA program director Mike Walker said the seven machines succeeded in identifying a total of 650 code vulnerabilities and rewriting 421 programs to fix them.

“A spark was lit today,” he said. “We have proven that autonomy is possible.”

Previous DARPA contests include one for self-driving vehicles that is widely credited with kick-starting the now robust autonomous-vehicle industry.

The hacking challenge included 96 rounds in which computers were charged with examining software programs, identifying bugs, patching them and finding ways to attack rival machines.

DARPA said it hoped the contest would speed the slow process of identifying and patching real-world bugs. It can take more than a year from the time a vulnerability is uncovered until a vendor releases a software patch, according to DARPA.

That delay gives hackers time to attack unprotected systems, one factor that security experts say has contributed to the surge in cyber attacks.

“Mayhem” was provisionally named winner, pending an overnight review of the results.

The winning program was created by eight computer experts from San Francisco and Pittsburgh, Pennsylvania. They are affiliated with Carnegie Mellon University, which regularly produces teams that earn top scores in the annual Def Con hacking contest.

Mayhem will compete against Carnegie Mellon students and other elite hackers when this year’s Def Con contest starts Friday. It is the first time a computer has competed.

Second place went to a program dubbed Xandra, created by security experts from the University of Virginia and GrammaTech Inc, earning $1 million.

A program known as Mech Phish, which was born at the University of California, placed third, earning its creators $750,000.