Genomic regions preferentially associate with regions of similar transcriptional activity, partitioning genomes into active and inactive compartments within the nucleus. Here we explore mechanisms controlling genome compartment organization inCaenorhabditis elegansand investigate roles for compartments in regulating gene expression. Distal arms ofC. eleganschromosomes, which are enriched for heterochromatic histone modifications H3K9me1/me2/me3, interact with each other bothin cisandin trans,while interacting less frequently with central regions, leading to genome compartmentalization. Arms are anchored to the nuclear periphery via the nuclear envelope protein CEC-4, which binds to H3K9me. By performing genome-wide chromosome conformation capture experiments (Hi-C), we showed that eliminating H3K9me1/me2/me3 through mutations in the methyltransferase genesmet-2andset-25significantly impaired formation of inactive Arm and active Center compartments.cec-4mutations also impaired compartmentalization, but to a lesser extent. We found that H3K9me promotes compartmentalization through two distinct mechanisms: Perinuclear anchoring of chromosome arms via CEC-4 to promote theircisassociation, and an anchoring-independent mechanism that compacts individual chromosome arms. In bothmet-2 set-25andcec-4mutants, no dramatic changes in gene expression were found for genes that switched compartments or for genes that remained in their original compartment, suggesting that compartment strength does not dictate gene-expression levels. Furthermore, H3K9me, but not perinuclear anchoring, also contributes to formation of another prominent feature of chromosome organization, megabase-scale topologically associating domains on X established by the dosage compensation condensin complex. Our results demonstrate that H3K9me plays crucial roles in regulating genome organization at multiple levels.