Shevus — Eruvin 68a
תלמוד בבלי מסכת עירובין דף סח/א
אמר ליה ולא שני לך בין שבות דאית ביה מעשה לשבות דלית ביה מעשה
The Gemara here distinguishes between a shevus — a Shabbos prohibition of Rabbinic origin — which involves an act and a shevus that does not involve an act. Both in the Gemara here and in Pesachim 65b we see that a Jew may never violate a shevus that involves an act, even if in so doing he will fulfill a mitzvah. However, the Gemara in Pesachim 66b makes it clear that under certain circumstances, for the purpose of fulfilling a mitzvah, a person may violate a shevus that involves an act — if he performs the act with a shinui — i.e., in a manner that differs from the normal manner in which this act is performed.
Accordingly, writes Teshuvos Tzitz Eliezer (2:3.4), the case in Gittin 8b, in which it is permitted to ask a non-Jew to write a bill of sale on land in Eretz Yisroel on Shabbos — even though asking a non-Jew to violate the Shabbos is in itself a shevus — must only be permitted because the act that the non-Jew does (in writing the bill of sale) is not attributed back to the Jew, so that vis-à-vis the Jew the shevus is one that does not involve an act.
On the basis of this principle, the Tzitz Eliezer forbids a Jew to milk a cow on Shabbos, even though the prohibition of milking is a shevus, and even though the animal is in anguish when it is not milked (tza'ar ba'alei chaim — removing tza'ar ba'alei chaim is the equivalent of fulfilling a mitzvah), unless the milking is done with a shinui.