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.
Islamists in Turkey long called for it to be converted to a mosque but secular opposition members opposed the move. The proposal prompted criticism from religious and political leaders worldwide.
Shortly after the move, the first call to prayer was recited at the Hagia Sophia and was broadcast on all of Turkey's main news channels. The cultural site's social media channels have now been taken down.