Shabbos, Perek Kirah, Mishnah 8. The Mishnah deals with the question of benefiting from work performed by a non-Jew on Shabbos: when may a Jew benefit from it, and when is it forbidden. The Mishnah lists three cases, and all of them rest on the same principle: everything depends on the question of for whose sake the work was done.
The three cases in the Mishnah:
"Nochri shehidlik es haner - mishtamesh l'oro Yisrael" - if a non-Jew lit a lamp or a flame on Shabbos, and the assumption is that he lit it for his own needs, a Jew may make use of its light. "V'im bishvil Yisrael - assur" - if he lit the lamp with the intention that the Jew use it, it is forbidden.
"Milei mayim l'hashkos behemto - mashkeh acharav Yisrael" - if a non-Jew draws water from a pit or a well, which are a private domain, and brings it out into the public domain in order to water his own animal, a Jew may use the water left over after him. "V'im bishvil Yisrael - assur".
"Asah goy kevesh leireid bo - yoreid acharav Yisrael" - a Jew and a non-Jew are together on a ship, and in order to disembark a gangplank is needed, that sloping board that leads down to dry land. If the non-Jew made a gangplank on Shabbos for his own descent, the Jew may go down after him. "V'im bishvil Yisrael - assur".
The Gemara's distinction between the cases:
The Gemara clarifies that the leniency regarding the water was stated specifically where the non-Jew is not acquainted with the Jew; but if he knows him, it is forbidden, because we are concerned that he may draw additional water for the Jew's sake. In the case of the lamp and the gangplank, by contrast, we are dealing with an all-or-nothing situation, in which there is no possibility of adding anything for the Jew, and therefore it makes no difference whether the non-Jew knows the Jew or not.
The incident with Rabban Gamliel and the Elders:
The Mishnah brings an incident that occurred: "Ma'aseh b'Rabban Gamliel u'zekeinim shehayu ba'im b'sfinah, v'asah goy kevesh leireid bo, v'yardu bo Rabban Gamliel v'hazekeinim". The non-Jew made the gangplank for his own needs, and Rabban Gamliel and the Elders went down after him in accordance with the halachah of our Mishnah.
The Tosefta explains that the case involved a ship that had arrived at port on Erev Shabbos, before Shabbos began. For a ship that arrives on Shabbos itself - one does not disembark from it onto dry land; only because it had arrived before Shabbos were they permitted to go down.
In summary: In this Mishnah we learned three cases of work done by a non-Jew on Shabbos - lighting a lamp, drawing water and making a gangplank - in all of which the leniency depends on the non-Jew having done the work for his own needs, whereas when he did it for a Jew, it is forbidden. We also examined the Gemara's distinction between drawing water, where there is a concern that he will add more when the non-Jew knows the Jew, and the lamp and the gangplank, which are an all-or-nothing situation, and the incident with Rabban Gamliel and the Elders who went down the gangplank, which the Tosefta explained by noting that the ship had arrived before Shabbos began.