Gestational edema occurs in late pregnancy secondary to increased venous congestion in the legs caused by pressure exerted mechanically by the uterus onto the inferior vena cava and iliac veins.