Bacteriophage are voracious predators of bacteria and a major determinant in shaping bacterial life strategies. Many phage species are virulent, meaning that infection leads to certain death of the host and immediate release of a large batch of phage progeny. Despite this apparent voraciousness, bacteria have stably coexisted with virulent phages for eons. Here, using individual-based stochastic spatial models, we study the conditions for achieving coexistence on the edge between two habitats, one of which is a bacterial refuge with conditions hostile to phage whereas the other is phage friendly. We show how bacterial density-dependent, or quorum-sensing, mechanisms such as the formation of biofilm can produce such refuges and edges in a self-organized manner. Coexistence on these edges exhibits the following properties, all of which are observed in real phage-bacteria ecosystems but difficult to achieve together in nonspatial ecosystem models: (i) highly efficient virulent phage with relatively long lifetimes, high infection rates and large burst sizes; (ii) large, stable, and high-density populations of phage and bacteria; (iii) a fast turnover of both phage and bacteria; and (iv) stability over evolutionary timescales despite imbalances in the rates of phage vs. bacterial evolution.