All praise is due to Allah, and peace and blessings be upon our master, the Messenger of Allah.
It is obligatory upon a Muslim to begin fasting when the commencement of Ramadan is confirmed in the country he is in, and to break his fast and celebrate Eid with the people of the country he is currently residing in.
Whoever starts fasting in one country and then travels to another should follow the people of that country in both fasting and breaking the fast, because by residing among them, he becomes one of them.
If the total number of days he fasts amounts to twenty-nine or thirty days, then his fasting is valid, since the lunar month may be either twenty-nine or thirty days. However, if the total reaches thirty-one days, he must still continue fasting in order to remain in accordance with the people of that country.
On the other hand, if he breaks his fast with them but his total number of fasting days amounts to only twenty-eight days, then he must make up one day afterward, because the lunar month cannot be twenty-eight days.
This is based on the hadith narrated by Abu Hurairah (may Allah be pleased with him), that the Prophet (peace and blessings be upon him) said: “Fasting is the day you all fast, breaking the fast is the day you all break the fast, and the Day of Sacrifice is the day you all offer sacrifice.” Imam al-Tirmidhi said: “This is a sound (hasan) and uncommon (gharib) hadith,” and some scholars explained that its meaning is that fasting and breaking the fast are to be observed with the the main body of Muslims.
It is mentioned in Asna al-Matalib fi Sharh Rawd al-Talib (Vol.1/P.411):
“If a person celebrates Eid in one land, then travels by ship to another land whose moon sighting differs, and finds them fasting, he must abstain for the remainder of the day, because by moving to them he has become one of them. Conversely, if he was fasting and then reaches people who have already broken their fast, he should break his fast with them… If he has fasted only twenty-eight days, he must make up one day, since the month cannot be that short. However, if he has fasted twenty-nine days, he does not need to make anything up, because the month may be twenty-nine days.” And Allah the Most High knows best.