An imidazole-functionalized metal−organic framework (MOF), {[Ba 2 L (H 3 CCOO) (DMF) 2 ] (DMF)} n , denoted as HBU-168, has been synthesized and characterized by single-crystal X-ray diffractometry. The synthesized MOF exhibits ligand-based luminescence, which can be attributed to coordination effects. Due to its excellent fluorescence performance, HBU-168 can be used to detect nitroaromatic compounds (NACs) and metal ions selectively and sensitively. The most striking properties of HBU-168 are the distinct red shift (∼34.8 nm) observed in the presence of picric acid (PA) with a Stern−Volmer constant (K SV ) of 4.17 × 10 4 . The mechanism of the change in luminescence in the presence of PA is determined by experiments and density functional theory calculations. The results indicate that the electron transfer between PA and the MOF has a reduction in the frontier orbital energy gap. Subsequently, HBU-168 is used to prepare a light-emitting-diode-based sensor (denoted HBU-168-LED), which can detect PA rapidly and visually. In addition, we find that HBU-168 can be used to detect metal ions, particularly magnesium ions. The metal detection mechanism is based on the turn-on fluorescence of HBU-168 caused by weak interactions between the MOF and metal ions. Finally, HBU-168 is found to be a good adsorbent for Congo red, achieving a removal efficiency of 98.89%. Therefore, the multifunctional HBU-168 MOF is a promising luminescent sensor and adsorbent.