The utilization of biomaterials for the separation of rare earth elements (REEs) has attracted considerable interest due to their inherent advantages, including diverse molecular structures for selective binding and the use of eco-friendly materials for sustainable systems. We present a pioneering methodology for developing a safe virus to selectively bind REEs and facilitate their release through pH modulation. We engineered the major coat protein of M13 bacteriophage (phage) to incorporate a lanthanide-binding peptide. The engineered lanthanide-binding phage (LBPh), presenting ∼3300 copies of the peptide, serves as an effective biological template for REE separation. Our findings demonstrate the LBPh's preferential binding for heavy REEs over light REEs. Moreover, the LBPh exhibits remarkable robustness with excellent recyclability and stability across multiple cycles of separations. This study underscores the potential of genetically integrating virus templates with selective binding motifs for REE separation, offering a promising avenue for environmentally friendly and energy-efficient separation processes.