In the southwestern margin of the Tertiary Ebro Basin (northeastern Spain) several evaporitic units are found among distal alluvial-fan deposits. They are made up of bioturbated microlenticular primary gypsum, secondary nodular and meganodular gypsum after anhydrite, chert nodules, and charophyte limestones. These evaporites formed in shallow saline lakes along the basin margin during the early Early Miocene (Autol gypsum unit) and the late Early Miocene (Ablitas, Gravalos, and Ribafrecha gypsum units). The lakes were fed principally by deeply circulated groundwaters loaded with dissolved salts from the old evaporite formations (mainly Triassic rocks) that make up the surrounding mountain chains. Shallow meteoric waters of low concentration also reached the lakes episodically. Concentration of these waters led to deposition of microlenticular gypsum and charophytic carbonates, which were then intensely bioturbated. Early-diagenetic chert nodules and nodular anhydrite also formed. In the early stages of burial large anhydrite nodules (meganodules) overprinted these sedimentary and early-diagenetic deposits. With more advanced burial the primary gypsum was profoundly anhydritized in some areas. With subsequent exhumation the anhydritized zones were transformed to secondary gypsum. Marginal lakes acted as preconcentrators of drainage waters coming from the surrounding mountain chains, causing early precipitation of low-solubility salts as Ca-carbonates, gypsum, and silica. The remaining dissolved salts then drained toward the basin center, where gypsum, anhydrite, glauberite, polyhalite, and halite precipitated in contemporaneous high-salinity lakes.