Defense-associated reverse transcriptase (DRT) systems perform DNA synthesis to protect bacteria against viral infection, but the identities and functions of their DNA products remain largely unknown. Here we show that DRT2 systems encode an unprecedented immune pathway that involves de novo gene synthesis via rolling circle reverse transcription of a non-coding RNA (ncRNA). Programmed template jumping on the ncRNA generates a concatemeric cDNA, which becomes double-stranded upon viral infection. Remarkably, this DNA product constitutes a protein-coding, nearly endless ORF ( neo ) gene whose expression leads to potent cell growth arrest, thereby restricting the viral infection. Our work highlights an elegant expansion of genome coding potential through RNA-templated gene creation, and challenges conventional paradigms of genetic information encoded along the one-dimensional axis of genomic DNA.