Q. I came home on Shabbos to a stream of ants and it was almost impossible to not step on them. Could I have swept them aside or is that just as much of a problem as stepping on them?
A. Killing animals including insects is part of the Biblical prohibition of Shechita, (Sacrificing animals for korbanot or eating meat. See Talmud Shabbos 107b) that even a small insect is included.
However, in practice Poskim disagree. Horav Ovadia Yosef zt”l and others rule that in your case the prohibition is only rabbinical (since one does not require the insects that are being killed) and one is not intending to perform the forbidden work.
Our case may be considered a situation where one performs an action whereby the forbidden work will certainly ensue; (P’sik Reisha). However, since one does not really care how the forbidden work is being performed and all one needs is the disappearance of the insects, the forbidden work is then only a Rabbinic prohibition, and in his case it will be permissible.
There is therefore no prohibition to walk on insects on Shabbos when one does not intend to kill them and use their bodies and all one needs is getting read of their disturbing presence. More so when they just may not even perish when steeping on them.
Poskim agree that it is nevertheless preferable not walk directly and step on the insects on Shabbos, as Chazon Ovadia-Shabbat, Volume 5, page 124 mentions: “One may not step on insects, such as ants, on Shabbos even if one does not intend to kill them, for they will surely die when one steps on them. One should be cautious of this in places where they are present. However, if one has no other way to walk, this is permissible.” She'ilat Yavetz 1:110.
Horav Shlomo Miller’s Shlit’a opinion is that during Summer days one should try to avoid such places. However, when not possible it is permitted.
Rabbi A. Bartfeld as revised by Horav Dovid Pam, Horav Aharon Miller, Horav Chanoch Ehrentreu and Horav Kalman Ochs Shlit'a.