Bacteria produce diverse specialized metabolites that mediate ecological interactions and serve as a rich source of industrially relevant natural products. Biosynthetic pathways for these metabolites are encoded by organized groups of genes called biosynthetic gene clusters (BGCs). Understanding the natural function and distribution of BGCs provides insight into the mechanisms through which microorganisms interact and compete. Further, understanding BGCs is extremely important for biocontrol and the mining of new bioactivities. Here, we investigated phage-encoded BGCs (pBGCs), challenging the relationship between phage origin and BGC structure and function. The results demonstrated that pBGCs are rare, and they predominantly reside within temperate phages infecting commensal or pathogenic bacterial hosts. Further, the vast majority of pBGCs were found to encode for bacteriocins. Using the soil- and gut-associated bacterium Bacillus subtilis, we experimentally demonstrated how a temperate phage equips a bacterium with a fully functional BGC, providing a clear competitive fitness advantage over the ancestor. Moreover, we demonstrated a similar transfer of the same phage in prophage form. Finally, using genetic and genomic comparisons, a strong association between pBGC type and phage host range was revealed. These findings suggest that bacteriocins are encoded in temperate phages of a few commensal bacterial genera. In these cases, lysogenic conversion provides an evolutionary benefit to the infected host and, hence, to the phage itself. This study is an important step toward understanding the natural role of bacterial compounds encoded by BGCs, the mechanisms driving their horizontal transfer, and the sometimes mutualistic relationship between bacteria and temperate phages.