Ruling on opening mosques with celebrations and gathering for that purpose
Question

                When a new mosque is built and they want to start praying in it, they invite people from the neighbouring countries and they gather for what they call the opening of the mosque. What is the ruling on their doing this? Does the hadeeth “Do not travel to visit any mosque except three…” indicate that this is haraam? If it is permissible, what is the evidence for that? Does the hadeeth which says that one of the Sahaabah invited the Prophet (peace and blessings of Allaah be upon him) to pray in a corner of his house so that he could take it as a prayer-place (musalla) indicate that it is permissible? Is there any evidence in the fact that in the story of Masjid al-diraar (the mosque built by the hypocrites) Allaah only forbade the Prophet (peace and blessings of Allaah be upon him) to go there because the mosque was built for the purpose of causing harm and was based on kufr?
Praise be to Allah.
    Mosques are opened by praying in them and maintaining them 
    with the remembrance of Allaah (dhikr), reading Qur’aan, glorifying and 
    praising Allaah, declaring His Oneness, teaching knowledge of sharee’ah, and 
    other things that will show respect to the place. Allaah says 
    (interpretation of the meaning): 
“In houses (mosques) 
    which Allaah has ordered to be raised (to be cleaned, and to be honoured), 
    in them His Name is remembered [i.e. Adhaan, Iqaamah, Salaah (prayers), 
    invocations, recitation of the Qur’aan]. Therein glorify Him (Allaah) in the 
    mornings and in the afternoons or the evenings,

    Men whom neither trade nor sale (business) diverts from 
    the remembrance of Allaah (with heart and tongue) nor from performing 
    As-Salaah (Iqaamat-as-Salaah) nor from giving the Zakaah. They fear a Day 
    when hearts and eyes will be overturned (out of the horror of the torment of 
    the Day of Resurrection).

    That Allaah may reward them according to the best of their 
    deeds, and add even more for them out of His Grace. And Allaah provides 
    without measure to whom He wills”[al-Noor 24:36-38]

    In these ways and others, by offering religious advice, 
    exhortation and consultation, the Messenger of Allaah  (peace and 
    blessings of Allaah be upon him) used to maintain the mosque, and he was 
    followed in that by the Rightly-Guided Khaleefahs and by all his Sahaabah 
    and the guided imams after him (may Allaah be pleased with them and have 
    mercy on them). All goodness resides in following their guidance and 
    adhering to their example in opening mosques and maintaining them as they 
    did, with acts of worship and other symbols of Islam. It was not narrated 
    that the Prophet  (peace and blessings of Allaah be upon him) or any of 
    the guided imams opened a mosque with celebrations or invitations like those 
    that people do nowadays, gathering from all over the country when the 
    building is complete to honour it. If that was a praiseworthy action, then 
    the Messenger of Allaah  (peace and blessings of Allaah be upon him) 
    would have been the first of people to do it and he would have prescribed it 
    as Sunnah for his ummah, and the Rightly-Guided Khaleefahs and guided imams 
    who came after him would have done it too. And if that had happened, it 
    would have been reported. 
On this basis, these 
    celebrations should not be held. It is not recommended to invite people to 
    such events or to help with them by giving money or in other ways. All good 
    resides in following those who went before (the salaf) and evil resides in 
    following those who came later. The fact that one of the Sahaabah invited 
    the Messenger of Allaah  (peace and blessings of Allaah be upon him) to 
    his house to pray two rak’ahs in one part of it so that the owner of the 
    house could take that as a prayer-place for praying whatever he could of 
    naafil prayers does not form evidence to support the modern practice of 
    holding celebrations to open mosques, because he (the Sahabi) did not invite 
    the Prophet  (peace and blessings of Allaah be upon him) to a 
    celebration, rather he invited him to pray, and he did not travel in order 
    to offer that prayer. Moreover, travel to attend this celebration or to pray 
    in that mosque comes under the general meaning of the prohibition on 
    traveling to pray in mosques other than the three famous mosques [i.e., 
    al-Masjid al-Haraam in Makkah, al-Masjid al-Nabawi in Madeenah and Masjid 
    al-Aqsa in al-Quds/Jerusalem]. So we should shun this innovated practice and 
    be content – with regard to mosques and other matters – with the things that 
    were done at the time of the Messenger of Allaah  (peace and blessings 
    of Allaah be upon him) and the guided imams who followed him (may Allaah 
    have mercy on them).