Many bacteria are adapted for attaching to surfaces and building complex communities, or biofilms. This mode of life is predominant in microbial ecology. So, too, is exposure of bacteria to viral pathogens, the bacteriophages. It is likely that biofilm-phage encounters are common in nature, but we know very little about how phages might interact with biofilm-dwelling bacteria. Making headway in this relatively unknown area requires new techniques, and here we develop the first biofilm simulation framework that captures key features of biofilm growth and phage infection. We describe the framework in detail and use it to study the population dynamics of lytic phages and susceptible bacterial hosts in biofilms. The system displays a rich array of dynamical steady states, and these are governed largely by nutrient availability to biofilms, phage infection likelihood, and the ability of phages to diffuse through biofilm populations. Interactions between the biofilm matrix and phage particles are likely to be of fundamental importance, controlling the extent to which bacteria and phages can coexist in natural contexts. Our results build on the rich literature exploring bacteria-phage interactions, and open avenues to new questions of host-parasite coevolution in the spatially structured biofilm context.