The question of whether tza'ar ba'alei chaim (the prohibition of causing undue pain to animals) is biblical (mideoraita) or rabbinic (miderabbanan) is the subject of significant debate in Bava Metzia 32b-33a.
According to those who hold that it is bibical, this article on wikiyeshiva (Hebrew), lists six possible sources:
- Rashi (Shabbat 128b) holds we learn it from Shemot 23:5:
כִּֽי־תִרְאֶ֞ה חֲמ֣וֹר שֹׂנַאֲךָ֗ רֹבֵץ֙ תַּ֣חַת מַשָּׂא֔וֹ וְחָדַלְתָּ֖ מֵעֲזֹ֣ב ל֑וֹ עָזֹ֥ב תַּעֲזֹ֖ב עִמּֽוֹ׃
When you see the ass of your enemy lying under its burden and would refrain from raising it, you must nevertheless raise it with him.
with the rationale behind this commandment understood to be because of tza'ar ba'alei chaim.
- Meiri (Bava Metzia 32b) holds that an additional source is the simple reading of Devarim 25:4:
לֹא־תַחְסֹ֥ם שׁ֖וֹר בְּדִישֽׁוֹ׃
You shall not muzzle an ox while it is threshing.
Ritva (Bava Metzia 32b) understands Rashi to hold, like you suggested, that it is a halachah lemosheh misinai.
טוֹב־יְהוָ֥ה לַכֹּ֑ל וְ֝רַחֲמָ֗יו עַל־כָּל־מַעֲשָֽׂיו׃
The LORD is good to all, and His mercy is upon all His works.
as the source.
- Rambam in Moreh Nevuchim III:17 brings as the source the rebuke given to Bil'am in Bamidbar 22:32:
וַיֹּ֤אמֶר אֵלָיו֙ מַלְאַ֣ךְ יְהוָ֔ה עַל־מָ֗ה הִכִּ֙יתָ֙ אֶת־אֲתֹ֣נְךָ֔ זֶ֖ה שָׁל֣וֹשׁ רְגָלִ֑ים הִנֵּ֤ה אָנֹכִי֙ יָצָ֣אתִי לְשָׂטָ֔ן כִּֽי־יָרַ֥ט הַדֶּ֖רֶךְ לְנֶגְדִּֽי׃
The angel of the LORD said to him, “Why have you beaten your ass these three times? It is I who came out as an adversary, for the errand is obnoxious to me.
- Finally, R. Moshe ibn Chaviv in Yom Teruah on Rosh HaShanah 27a brings this verse (Bamidbar 20:8) as a source:
קַ֣ח אֶת־הַמַּטֶּ֗ה וְהַקְהֵ֤ל אֶת־הָעֵדָה֙ אַתָּה֙ וְאַהֲרֹ֣ן אָחִ֔יךָ וְדִבַּרְתֶּ֧ם אֶל־הַסֶּ֛לַע לְעֵינֵיהֶ֖ם וְנָתַ֣ן מֵימָ֑יו וְהוֹצֵאתָ֨ לָהֶ֥ם מַ֙יִם֙ מִן־הַסֶּ֔לַע וְהִשְׁקִיתָ֥ אֶת־הָעֵדָ֖ה וְאֶת־בְּעִירָֽם׃
“You and your brother Aaron take the rod and assemble the community, and before their very eyes order the rock to yield its water. Thus you shall produce water for them from the rock and provide drink for the congregation and their beasts.”
which indicates that G-d was worried about the pain of the animals.