Some Muslim scholars believed that the Prophet Muhammad (PBUH) ordered the mosque be demolished but not burnt.
The researchers have found out that Dirar Mosque was located near Quba mosque. And it was built by Abu Amir, who was a monk and Hypocrite.
Abu Amir and his men were not loyal or respectful towards Islam and their intention was not to build a mosque to worship but to use it against the Muslims. They built this mosque to gather the sympathies of Muslims so they can freely plan new traps for Muslims at that time.
It was Holy Quran’s verse 9:107, which stated that this mosque was built by the hypocrites so they can trap the Muslims. They can use this mosque to start fitnah between the Muslims and a safe house for the people who were in the war against Allah and his last Prophet Muhammad (PBUH).
When this mosque was built, Abu Amir invited Prophet Muhammad PBUH to pray in that mosque, which he accepted as the Quranic verse was not revealed onto him at that point. Since Prophet Muhammad (PBUH) had to leave for the Battle of Tabuk, so he decided to offer the prayer when he returns from battle.
At Tabari narrates this incident, when Prophet Muhammad (PBUH) was on his way towards the Battle of Tabuk, when he read Dhu Awan, a group of men came to him and asked him to pray in the mosque (Dirar Mosque), they claimed that they build this mosque to help the sick and needy in the cold and rainy nights. Prophet (PBUH) accepted their invitation and told them that he will pray once he returns from Battle of Tabuk.
When Prophet Muhammad (PBUH) returned from the Battle of Tabuk it was when Holy Quran’s verse 9:107 was revealed onto him which unveiled the truth of this mosque.
Allah clearly forbade Prophet PBUH from praying in that mosque as per Quran 9:108. After these ayahs were revealed to him, he ordered his men to Demolish the mosque and burn it to the ground.
Then his men went and burned down the mosque, so it was the mosque Dirar a mosque which Prophet Muhammad PBUH ordered to burn.