It is written concerning Noah (Genesis 6:9), "Noah walked with God," and it is written concerning Abraham, "Walk before Me." One who reads this might suppose that Noah was greater than Abraham, but it is not so. Rabbi Yochanan and Resh Lakish differed. Rabbi Yochanan said: A parable. To what is the matter comparable? To a king who had two sons, one grown and one small. The small one would hold onto him so that he would not fall, but the grown one would walk before him. So it is written concerning Noah, "Noah walked with God," so that he would not be sunk away with the generation of the flood. But Abraham, who was the only one of his kind in the world and was righteous, to him the Holy One, blessed be He, said, "Walk before Me and be perfect." Resh Lakish said: A parable. To what is the matter comparable? To a king who had a beloved friend who was sunk in the mire, and he took hold of his hand and raised him up out of the mire. So Noah was sunk in the mire; the Holy One, blessed be He, saw him, gave him a hand, and raised him up out of the mire. And to what was Abraham comparable? To a king who was walking in the darkness. His beloved friend came and saw him and gave him light. The king said to him, "Since you are giving light to me, come and walk before me." So [in the days of] Abraham the whole world was wicked, and he was righteous. The Holy One, blessed be He, said to him, "Since you are giving light in the east, walk before Me."
Why Abraham Walked Before God and Noah Only With Him
Midrash Tanchuma Buber, Lech Lecha 26:1
כתיב בנה את האלהים התהלך נח (בראשית ו ט), וכתיב באברהם התהלך לפני, מי שהוא קרוא סבור שהיה נח גדול מאברהם, ואינו כן, ר' יוחנן וריש לקיש, ר' יוחנן אמר משל למה הדבר דומה, למלך שהיו לו שני בנים, אחד גדול ואחד קטן, הקטן היה אוחז בו כדי שלא יפול, והגדול היה הולך לפניו, כך כתיב בנח את האלהים התהלך נח, שלא ישתקע בדור המבול, אבל אברהם שהיה יחידו של עולם והיה צדיק, א"ל הקב"ה התהלך לפני והיה תמים, אמר ריש לקיש משל למה הדבר דומה, למלך שהיה לו אוהב, והיה משוקע בטיט, ואחז בידו והעלה אותו מן הטיט, כך נח היה משוקע בטיט, ראהו הקב"ה נתן לו יד והעלהו מן הטיט, ואברהם למה היה דומה, למלך שהיה מהלך בחשיכה, בא אוהבו וראה אותו והאיר לו, א"ל המלך עד שאתה מאיר לי, בא והלך לפני, כך [בימי] אברהם היו כל העולם רשעים והוא צדיק, א"ל הקב"ה עד שאתה מאיר במזרח התהלך לפני.