Scientists have worked out how bacteria sense an invading virus and switch on a self-destruct defense that kills the infected cell before the virus can spread, according to a study published on Thursday in the journal Science.

The answer, the researchers found, is a cut. Certain viruses carry an enzyme called a protease that degrades other proteins, and when that enzyme slices a sensor molecule in the bacterium, the immune system turns on. The discovery could matter well beyond the petri dish. Bacteriophages, or phages, are a rapidly developing therapy that can kill drug-resistant bacteria while leaving human cells alone, and knowing how bacteria detect them may let scientists build treatment phages that evade those defenses. Laboratories are already stockpiling phages against bacteria that have learned to shrug off antibiotics.

“This is one of the most common forms of bacterial immunity, so when we finally figured it out, it was a total eureka moment,” said Sam Hobbs, an assistant professor of biochemistry at University of Utah Health and the paper’s first author.

The defense Dr. Hobbs studied is called CBASS, one part of the bacterial immune system. It is a last resort, killing the bacterium itself before viruses can spread to the cell’s neighbors. With a consequence that final, the system cannot afford false alarms, so precise sensing of the viral trigger is a necessity.

The signal turned out to be something the virus needs to survive. “Certain kinds of phages have a protein called a protease, which degrades other proteins,” Dr. Hobbs said. “We found that the protease from the phage actually acts directly on the host protein, and that is the signal that turns on the whole signaling pathway.”

Related antiviral pathways in bacteria switch on when they detect viral genetic material. This trigger is different. “This is a totally new mechanism for how these host proteins are activated,” Dr. Hobbs said. “I never would have guessed that this was the way it was going to work.”

The work may also sharpen what researchers know about the human immune system. CBASS resembles an immune pathway in people, which suggests the system has persisted since bacteria and humans last shared an ancestor. And because bacteria live and die fast, scientists can use them to answer questions about immunity quickly, then test the answers in models closer to humans.

“The fact that these systems are conserved between bacteria and humans suggests that they’ve been maintained in these different organisms for that entire evolutionary trajectory,” Dr. Hobbs said. “The cells are telling us that this is a really important pathway because they’ve maintained it for billions of years. It’s incredibly fascinating, and it’s a cool window into what’s important in maintaining the ability to fight viruses.”

The paper, “Phage proteases activate CBASS antiphage immunity,” appeared Oct. 1. Dr. Hobbs’s co-author is Philip J. Kranzusch, a professor of microbiology at Harvard Medical School. The work was supported by the National Institute of General Medical Sciences of the National Institutes of Health and by several private foundations.