Should a traveler pray four rak’ahs with the congregation or pray two rak’ahs on his own?
Question

                I was traveling, then whilst I was on a journey, I stopped to pray Maghrib and ‘Isha’ together and shortened in one of the mosques. After I had prayed Maghrib and intended to pray ‘Isha’, I found that a group had given the iqaamah to pray ‘Isha’ in the mosque. Should I have prayed four rak’ahs with that congregation, or should I have prayed two rak’ahs on my own as I had intended to, and completed my journey?.
Praise be to Allah.
    Prayer in congregation is obligatory for men whether they are 
    at home or traveling. If you find a group of travelers, you should pray 
    ‘Isha’ with them, in the shortened form, otherwise you should pray four 
    rak’ahs in congregation with the people who live there. 

    Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said: 
    “The obligation to pray in congregation is not waived for the traveler, 
    because Allaah has enjoined it (prayer in congregation) even at the time of 
    battle, as He says (interpretation of the meaning): 
“When you (O Messenger 
    Muhammad) are among them, and lead them in As-Salaah (the prayer), let one 
    party of them stand up [in Salaah (prayer)] with you taking their arms with 
    them; when they finish their prostrations, let them take their positions in 
    the rear and let the other party come up which have not yet prayed, and let 
    them pray with you”

    [al-Nisa’ 4:102]

    Based on this, if the traveler is in a country other than his 
    own, he has to attend prayer in congregation in the mosque if he hears the 
    adhaan, unless he is far away from the mosque or fears that he will lose his 
    traveling-companions, because of the general meaning of the evidence which 
    indicates that it is obligatory to pray in congregation for the one who 
    hears the adhaan or iqaamah. 

    From Majmoo’ Fataawa al-Shaykh Ibn ‘Uthaymeen, vol. 
    15, question no. 1085. and Allaah knows best.