Turkey's President Recep Tayyip Erdogan announced the decision after a court annulled the site's museum status.
Built 1500 years ago as an Orthodox Christian cathedral, Hagia Sophia was converted into a mosque after the Ottoman conquest in 1453.
In 1934 it became a museum and is now a Unesco World Heritage site.
Defending the move, a Turkish official stressed that tourists could still visit the site after it once more became a mosque.
"May it be beneficial," Erdogan said on Twitter, sharing a caption of the decision with his signature.