The most abundant mRNA post-transcriptional modification is N(6)-methyladenosine (m(6)A), which has broad roles in RNA biology. In mammalian cells, the asymmetric distribution of m(6)A along mRNAs results in relatively less methylation in the 5' untranslated region (5'UTR) compared to other regions. However, whether and how 5'UTR methylation is regulated is poorly understood. Despite the crucial role of the 5'UTR in translation initiation, very little is known about whether m(6)A modification influences mRNA translation. Here we show that in response to heat shock stress, certain adenosines within the 5'UTR of newly transcribed mRNAs are preferentially methylated. We find that the dynamic 5'UTR methylation is a result of stress-induced nuclear localization of YTHDF2, a well-characterized m(6)A 'reader'. Upon heat shock stress, the nuclear YTHDF2 preserves 5'UTR methylation of stress-induced transcripts by limiting the m(6)A 'eraser' FTO from demethylation. Remarkably, the increased 5'UTR methylation in the form of m(6)A promotes cap-independent translation initiation, providing a mechanism for selective mRNA translation under heat shock stress. Using Hsp70 mRNA as an example, we demonstrate that a single m(6)A modification site in the 5'UTR enables translation initiation independent of the 5' end N(7)-methylguanosine cap. The elucidation of the dynamic features of 5'UTR methylation and its critical role in cap-independent translation not only expands the breadth of physiological roles of m(6)A, but also uncovers a previously unappreciated translational control mechanism in heat shock response.