Many plants and animals are defended from predation or herbivory by inhibitory secondary metabolites, which in the marine environment are very common among sessile organisms. Among bacteria, where there is the greatest metabolic potential, little is known about chemical defenses against bacterivorous consumers. An emerging hypothesis is that sessile bacterial communities organized as biofilms serve as bacterial refuge from predation. By testing growth and survival of two common bacterivorous nanoflagellates, we find evidence that chemically mediated resistance against protozoan predators is common among biofilm populations in a diverse set of marine bacteria. Using bioassay-guided chemical and genetic analysis, we identified one of the most effective antiprotozoal compounds as violacein, an alkaloid that we demonstrate is produced predominately within biofilm cells. Nanomolar concentrations of violacein inhibit protozoan feeding by inducing a conserved eukaryotic cell death program. Such biofilm-specific chemical defenses could contribute to the successful persistence of biofilm bacteria in various environments and provide the ecological and evolutionary context for a number of eukaryote-targeting bacterial metabolites.