The Talmud discusses the concept of 'grama' (indirect causation) in the context of extinguishing fire on Shabbat, establishing that causing a fire to go out indirectly is treated differently from direct extinguishing. This is the foundational sugya for all later discussion of gerama in melachot.
אֵימַר דְּאָמַר רַבִּי שִׁמְעוֹן בֶּן נַנָּס ״מִפְּנֵי שֶׁהוּא מְחָרֵךְ״, גְּרַם כִּיבּוּי מִי אָמַר? אִין, מִדְּקָתָנֵי סֵיפָא רַבִּי יוֹסֵי אוֹסֵר בִּכְלֵי חֶרֶס חֲדָשִׁים מְלֵאִים מַיִם, שֶׁאֵינָן יְכוֹלִים לְקַבֵּל אֶת הָאוּר וְהֵן מִתְבַּקְּעִין וּמְכַבִּין אֶת הַדְּלֵיקָה — מִכְּלָל דְּתַנָּא קַמָּא שָׁרֵי. אִי הָכִי, הָכָא נָמֵי, כְּתִיב: ״לֹא תַעֲשֶׂה [כׇל] מְלָאכָה״ — עֲשִׂיָּיה הוּא דְּאָסוּר, גְּרָמָא שְׁרֵי! מִתּוֹךְ שֶׁאָדָם בָּהוּל עַל מָמוֹנוֹ, אִי שָׁרֵית לֵיהּ — אָתֵי לְכַבּוֹיֵי.
The Gemara asks: Say that Rabbi Shimon ben Nannas said it is permitted to place the goat’s hide on the burning item because it singes and does not burn; did he say it is permitted to indirectly cause the fire to extinguish? The Gemara answers: Yes, Rabbi Shimon ben Nannas permitted that as well, and we learn this from that which is taught in the latter clause in the mishna: Rabbi Yosei prohibits using new earthenware vessels that are full of water, because they cannot withstand the fire and will burst and extinguish the fire. This proves by inference that the first tanna, Rabbi Shimon ben Nannas, permits it. The Gemara asks: If so, here too, with regard to Shabbat, it is written: “And the seventh day is Shabbat for the Lord your God, you shall not perform any labor” (Exodus 20:9). And here, too, one could derive: Performance is that which is prohibited; indirectly causing a prohibited action is permitted. The Gemara answers: Actually, Rabbi Yosei maintains there is no prohibition in indirectly causing a fire to be extinguished; however, since a person is agitated about his property, if you permit him to indirectly extinguish the fire, he will come to extinguish it directly.