In this work, the MoS 2 functionalized AlGaN/GaN high-electron mobility transistor (HEMT) was utilized for the first time to detect toxic mercury (Hg 2+ ) ions under ultraviolet (UV) illumination. The AlGaN/GaN HEMT was fabricated on the sapphire substrate, and corresponding structural and electrical properties were investigated. Subsequently, the optimization of MoS 2 concentration for device functionalization was carried out by performing sensing analysis of Hg 2+ ions on three devices, and it was observed that the 20 mg/mL concentration of MoS 2 is optimum for the detection of Hg 2+ ions. Furthermore, the detection of Hg 2+ ions was performed under UV exposure, where the developed sensor showed much-improved sensitivity of $548.07~\mu \text{A}$ /ppb compared with normal light. The comparative analysis indicates the increase of three orders of magnitude in sensitivity under UV irradiation, and it is the highest sensitivity ever observed by the AlGaN/GaN HEMT sensor for Hg 2+ ion detection. Moreover, the sensor also exhibits the limit of detection (LoD) of 6.14 parts per trillion (ppt) that is much lower than the World Health Organization (WHO) standard limit for Hg 2+ ions in drinking water. Due to the photoexcitation process, the generation of electron–hole pairs provides more binding sites on the MoS 2 surface, which results in the ultrasensitive detection of the Hg 2+ ions at trace and ultratrace levels.