The foundational source is Yoma 28b:9-10, where the Gemara states that Avraham fulfilled the entire Torah before it was given, deriving this from the pasuk "because Avraham hearkened to My voice and kept My charge, My mitzvot, My statutes and My Torahs" (Bereishit 26:5), and pushes the derivation further to show that even eruvei tavshilin — a rabbinic enactment — is included, since "Torahs" in the plural alludes to both the Written and Oral Torah.
Bereshit Rabbah 95:3 and Bereshit Rabbah 61:1 explain the mechanism behind this knowledge: since Torah had not yet been given, Avraham could not have learned it from a teacher, so Chazal describe his two kidneys as functioning like two flasks or two sages, welling up and teaching him Torah and wisdom directly; this midrash likewise applies the point specifically to eruvei tavshilin, the same rabbinic-level example singled out in the Gemara.
Among the meforshim, Rashi (Bereishit 26:5) and the Ramban (Bereishit 26:5) read the four terms of the pasuk as encompassing distinct categories — mishmarti as rabbinic safeguards like sheniyot la'arayot and shevut leShabbat, mitzvotai as rationally self-evident laws, chukotai as decrees without apparent reason, and torotai as bringing in the Oral Torah including halacha leMoshe miSinai — so that the pasuk itself textually accounts for Avraham's grasp of rabbinic-level law.
Gur Aryeh (Bereishit 26:5) cites the Ramban's answer that the Avos learned the whole Torah through ruach hakodesh exactly as it was later transmitted to Israel, and kept it as one who is not commanded yet performs, explaining why Yaakov's marriage to two sisters was still possible: the Avos' observance was voluntary and bound only to Eretz Yisrael, so conduct outside the land did not breach it, a point also raised by Siftei Chakhamim (Bereishit 26:5:1).
Or HaChaim (Bereishit 26:5) reads the pasuk itself as describing a process of active study rather than mere compliance, explaining that torotai means Avraham studied the mitzvot so as not to forget them, parallel to Moshe's command to Israel in Devarim.
Tiferet Yisrael 20:1 distinguishes gradations among the Avos: Avraham alone was uniquely fit to fulfill the entire Torah by the very understanding of the Sages described in Yoma 28b:9-10, because his greatness was bound up with the supernal wisdom itself, whereas Yitzchak and Yaakov received this from Avraham rather than attaining it independently.
Peri Tzadik, Lech Lecha 8 develops the theme that "torotai" in the plural alludes to the Oral Torah, explaining that the fine details (dikdukei mitzvot) which make up the Oral Torah's extensive halachic structure were already included in what Avraham observed, and that only one who loves G-d fully can attain this level of learning.
Dover Tzedek, Miscellany 3:12 frames Avraham's achievement as beginning from the sechel enabling the seven Noahide laws, a natural grounding below Torah, from which he rose by his own effort until meriting the title "ezrachi" and his kidneys flowing with Torah, showing that divine guidance builds upon a person's own exertion of intellect and will.
Abarbanel on Torah, Shemot 19:1 addresses directly the conceptual problem the question raises: if the Avos already received mitzvot from G-d and kept the whole Torah as described of Avraham, why is the giving of the Torah attributed solely to Moshe, and he insists that the commandments given to Adam and Noach truly came from G-d's command rather than being merely natural or conventional norms, rejecting those who deny that attribution.
Other sources touch related aspects of this same theme: Rashi (Bereishit 18:19) reads "lema'an asher yetzaveh" as Avraham's commanding his descendants to guard G-d's ways, Berakhot 40a:11 is invoked for the exposition of "im shamoa tishma" tied to the same pasuk's language of hearkening, Peri Tzadik, Beha'alotcha 10:1 draws out that the Avos did not need the same safeguards later generations required, and Meshekh Chokhmah, Lekh Lekha 24-25 and Rashi (Bereishit 25:27) and Peri Tzadik, Shavuot 22 and Esh Kodesh, Jewish Year 5700, Shavuot 3 likewise engage the broader question of how Torah knowledge, including its finer halachic layers, was transmitted and recognized even before Sinai.
Igros Moshe (OC 4:39) addresses how engaging in the relevant Torah study enables a person to understand halachic rulings for practical application, including laws tied to specific times, and notes that this dimension of study has no fixed measure, bearing on how depth of halachic knowledge can be attained outside the ordinary process of transmission.
Az Nidberu (14:4) addresses the historical role of ancestral tradition itself, noting that in earlier times when people remained rooted in their ancestors' ways, there was certainly great value in teaching them Torah broadly, which bears on how the Avos' own grasp of Torah could pass down through inherited practice and teaching rather than formal transmission.