We report a novel magnetic ionic liquid (MIL) based on pyridine successfully prepared by a two-step reaction pathway. The prepared MIL was recognized by means of Fourier transform infrared spectroscopy (FT-IR), UV-visible and Raman spectroscopies, thermal analysis (TGA and DTG), magnetic susceptibility measurement, mass spectra (MS), proton NMR (1HNMR\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$<^>{1}\hbox {H}\,\hbox {NMR}$$\end{document}), carbon NMR (13CNMR\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$<^>{13}\hbox {C}\,\hbox {NMR}$$\end{document}), Hammett acidity, and CHN elemental analysis. The MIL was shown to be efficient in the synthesis of xanthenediones under solvent-free conditions. In addition, the antibacterial and antifungal activity of the MIL was investigated.