All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu 'alyhi wa sallam, is His slave and Messenger.
In principle, it is the obligation of a Muslim to cooperate with his Muslim brothers who work towards establishing the religion, spreading Islam and teaching those who are ignorant. Such actions are cooperation in righteousness and piety which Allaah The Almighty commanded us to do. In this regard, He Says (what means): {And cooperate in righteousness and piety, but do not cooperate in sin and aggression.} [Quran 5: 2]
Joining secularist and communist parties or Masonic organizations is impermissible under Sharee'ah (Islamic law) because they publicly and secretly fight Islam and bear enmity towards Muslims. Most of them work for the benefit of international Zionism or Christians that are still carrying out their crusades. At the same time, many of their leaders pretend to be working for Islam and propagate slogans of nationalism and patriotism in order to deceive the common people.
Unfortunately, they have succeeded in deceiving and attracting many of them. There is no doubt that joining these parties is forbidden because Allaah The Almighty commanded us not to cooperate in sin and aggression as indicated in the aforementioned verse. However, if a Muslim lives in a non-Muslim country and risks being harmed if he does not join a party or organization that would protect him or safeguard himself against injustice, then in this case it is permissible for him to do so due to necessity. However, the extent of necessity determines the extent of allowing something that is prohibited.
As for joining these parties in order to serve Islam, unless the Muslim ruler or his deputy permits him to do so, a Muslim is not permitted to join them because he is exposing himself to great risk. It was reported that the Prophet, sallallaahu ‘alayhi wa sallam, entrusted some of his Companions to do certain tasks within the ranks of the disbelievers. One of them was Nu‘aym ibn Mas‘ood during the Battle of Al-Ahzaab. [Seerat Ibn Hishaam, Saheeh Al-Bukhari and Saheeh Muslim]
On another occasion, the Prophet, sallallaahu ‘alayhi wa sallam, entrusted a certain task to ‘Abd Allaah ibn Unays and ordered him to join the tribe of Khuzaa‘ah. [Seerat Ibn Hishaam, Abu Daawood and others]
In conclusion, it is impermissible for a Muslim to join dubious parties and organizations unless it is absolutely necessary to do so, or when the Muslim ruler or his deputy commands someone to join them.
Allaah Knows best.