Bacteria form dense surface-associated communities known as biofilms that are central to their persistence and how they affect us. Biofilm formation is commonly viewed as a cooperative enterprise, where strains and species work together for a common goal. Here we explore an alternative model: biofilm formation is a response to ecological competition. We co-cultured a diverse collection of natural isolates of the opportunistic pathogen Pseudomonas aeruginosa and studied the effect on biofilm formation. We show that strain mixing reliably increases biofilm formation compared to unmixed conditions. Importantly, strain mixing leads to strong competition: one strain dominates and largely excludes the other from the biofilm. Furthermore, we show that pyocins, narrow-spectrum antibiotics made by other P. aeruginosa strains, can stimulate biofilm formation by increasing the attachment of cells. Side-by-side comparisons using microfluidic assays suggest that the increase in biofilm occurs due to a general response to cellular damage: a comparable biofilm response occurs for pyocins that disrupt membranes as for commercial antibiotics that damage DNA, inhibit protein synthesis or transcription. Our data show that bacteria increase biofilm formation in response to ecological competition that is detected by antibiotic stress. This is inconsistent with the idea that sub-lethal concentrations of antibiotics are cooperative signals that coordinate microbial communities, as is often concluded. Instead, our work is consistent with competition sensing where low-levels of antibiotics are used to detect and respond to the competing genotypes that produce them.