When Avimelech took Sarah, Hashem came to him in a dream and told him to return Avraham's wife (Bereishis 20:3). When Pharaoh took her, no such event is recorded in the Torah. Pharaoh's household was afflicted with some kind of disease, and then he returned her to her husband (Bereishis 12:17-18).
I realize that Hashem could have told Pharaoh also, and it just isn't relevant for some reason. But is there any source that explains how Pharaoh knew?
Additionally, why the discrepancy between Avimelech and Pharaoh?