It goes without saying that performing Prayer in congregation is sunnahmu’akkadah (confirmed sunnah). Many hadiths discuss the virtue and importance of performing Prayer in congregation. One person with the imam would constitute a congregation, even if the other person is a child or a woman.
Sheikh Ahmad Kutty, a senior lecturer and Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states: Prayer in congregation is far more meritorious and rewarding than praying individually. The Prophet (peace and blessings be upon him) said, “Prayer in jama`ah surpasses in merit to praying individually by twenty-seven degrees.” We are therefore advised to seize each and every opportunity to pray in congregation as best as we can. Although the greater the number the greater the rewards, it is still recommended and rewarding for two persons to pray in jama`ah: This is the rule applicable in normal times when we are dealing with the situation of men and women praying all by themselves or if they are family members, as long as they are mahram (close blood relations who are not allowed to forge marriage ties): for instance, husband and wife, brother and sister, father and daughter, or mother and son praying together.
If, however, one of them is a man and another is a woman and they are not mahram (close relatives) but strangers, then it is not advisable for them to pray together in congregation, especially if by doing so they are risking the sin of isolation, which may expose them inadvertently to Satanic temptations. The Prophet (peace and blessings be upon him) has warned us against isolating ourselves with a member of the opposite sex: “No man will be isolated with a woman without Satan joining them as their third companion.”