Active genes in yeast can be targeted to the nuclear periphery through interaction of cis-acting "DNA zip codes" with the nuclear pore complex. We find that genes with identical zip codes cluster together. This clustering was specific; pairs of genes that were targeted to the nuclear periphery by different zip codes did not cluster together. Insertion of two different zip codes (GRS I or GRS III) at an ectopic site induced clustering with endogenous genes that have that zip code. Targeting to the nuclear periphery and interaction with the nuclear pore is a prerequisite for gene clustering, but clustering can be maintained in the nucleoplasm. Finally, we find that the Put3 transcription factor recognizes the GRS I zip code to mediate both targeting to the NPC and interchromosomal clustering. These results suggest that zip-code-mediated clustering of genes at the nuclear periphery influences the three-dimensional arrangement of the yeast genome.