The fools among the people will say, “What has turned them [Muslims] from the qiblah to which they were used?” Say: To Allah belong both East and West; He guides whom He pleases to a Way that is straight.)- (Al-Baqarah 2:142)
Nearly 18 months after the establishment of the Islamic state in Madinah, new Quranic revelations instructed the Prophet and the Muslims to turn towards the Kabah in Makkah when they prayed instead of Al-Masjid Al-Aqsa in Jerusalem.
Before changing the Qiblah (Arabic for: the direction of the Ka`bah — Islam’s holiest mosque — that Muslim turn to when praying), Prophet Muhammad (peace and blessings be upon him) in his heart, was longing to face Ka`bah in his Prayers. Answering his invocation, Almighty Allah ordered the change of Qiblah, from Jerusalem to Makkah.
( We have seen the turning of your face to heaven (for guidance, O Muhammad). And now verily We shall make you turn (in prayer) toward a qiblah which is dear to you. So turn your face toward the Inviolable Place of Worship, and ye (O Muslims), wheresoever you may be, turn your faces when you pray) toward it.) (Al-Baqarah 2: 144)
This happened in the middle of Sha`ban.
History of Qiblatain
The name of the mosque goes back to the event of Qiblah change. Prophet Muhammad (PBUH) was leading the prayer when he received a revelation from Allah instructing him to take the Kaaba as the Qiblah.
According to traditional accounts, Prophet Muhammad (PBUH), who had been facing Jerusalem during the prayer, upon receiving this revelation, immediately turned around to face Mecca, and those praying behind him also did so. After this, the mosque in which this incident occurred came to be known as Masjid al-Qiblatain (i.e. ‘Mosque of the Two Qiblas’).
Masjid Al-Qiblatain used to uniquely contain two mehrabs (niches), one in the direction of Al-Aqsa mosque and the other towards Makkah. However, the old mehrab has now been removed.
Many pilgrims who go to Mecca for hajj often visit Medina where some end up visiting the notable Qiblatain because of its historic significance. Wikipedia