The realization of lanthanide-doped upconversion nanocrystals embedded in a robust and transparent solid medium is highly desired to achieve deep UV (<300nm) lasing. Here, we fabricate NaGdF4:Yb3+,Tm3+ upconversion nanocrystals inside amorphous borosilicate glass to support ∼290nm random lasing emission under 980 nm excitation. We found that with careful control of the growth process, which is the key to achieve high-crystallinity nanocrystals, the nanocrystals can suppress defect-related quenching and enhance 1I6→3H6(6IJ→8S7/2) transition of Tm3+ (Gd3+) ions under five-photon absorption excitation so that high optical gain (>45cm-1) at ∼290nm can be obtained.