Mangroves are adapted to harsh environments, such as high ultraviolet (UV) light, low nutrition, and fluctuating salinity in coastal zones. However, little is known about the transcriptomic and epigenomic basis of the resilience of mangroves due to limited available genome resources. We performed a de novo genome assembly and in natura epigenome analyses of the mangrove Bruguiera gymnorhiza, one of the dominant mangrove species. We also performed the first genome-guided transcriptome assembly for mangrove species. The 309 Mb of the genome is predicted to encode 34 403 genes and has a repeat content of 48%. Depending on its growing environment, the natural B. gymnorhiza population showed drastic morphological changes associated with expression changes in thousands of genes. Moreover, high-salinity environments induced genome-wide DNA hypermethylation of transposable elements (TEs) in the B. gymnorhiza. DNA hypermethylation was concurrent with the transcriptional regulation of chromatin modifier genes, suggesting robust epigenome regulation of TEs in the B. gymnorhiza genome under high-salinity environments. The genome and epigenome data in this study provide novel insights into the epigenome regulation of mangroves and a better understanding of the adaptation of plants to fluctuating, harsh natural environments.