Termination of protein synthesis occurs when a translating ribosome encounters one of three universally conserved stop codons: UAA, UAG or UGA. Release factors recognize stop codons in the ribosomal A-site to mediate release of the nascent chain and recycling of the ribosome. Bacteria decode stop codons using two separate release factors with differing specificities for the second and third bases. By contrast, eukaryotes rely on an evolutionarily unrelated omnipotent release factor (eRF1) to recognize all three stop codons. The molecular basis of eRF1 discrimination for stop codons over sense codons is not known. Here we present cryo-electron microscopy (cryo-EM) structures at 3.5-3.8 Å resolution of mammalian ribosomal complexes containing eRF1 interacting with each of the three stop codons in the A-site. Binding of eRF1 flips nucleotide A1825 of 18S ribosomal RNA so that it stacks on the second and third stop codon bases. This configuration pulls the fourth position base into the A-site, where it is stabilized by stacking against G626 of 18S rRNA. Thus, eRF1 exploits two rRNA nucleotides also used during transfer RNA selection to drive messenger RNA compaction. In this compacted mRNA conformation, stop codons are favoured by a hydrogen-bonding network formed between rRNA and essential eRF1 residues that constrains the identity of the bases. These results provide a molecular framework for eukaryotic stop codon recognition and have implications for future studies on the mechanisms of canonical and premature translation termination.