We derive homogeneous abundances of Fe, O, Na, and α-elements from high-resolution FLAMES spectra for 76 red giant stars in NGC 6715 (M54) and for 25 red giants in the surrounding nucleus of the Sagittarius (Sgr) dwarf galaxy. Our main findings are the following. (1) We confirm that M54 shows intrinsic metallicity dispersion, ~0.19 dex rms. (2) When the stars of the Sgr nucleus are included, the metallicity distribution strongly resembles that in ω Cen; the relative contribution of the most metal-rich stars is, however, different in these two objects. (3) In both globular clusters (GCs) there is a very extended Na-O anticorrelation, which is a signature of different stellar generations born within the cluster. (4) The metal-poor and metal-rich components in M54 (and ω Cen) show clearly distinct extension of the Na-O anticorrelation, the most heavily polluted stars being those of the metal-rich component. We propose a tentative scenario for cluster formation that could explain these features. Finally, similarities and differences found in the two most massive GCs in our Galaxy can be easily explained if they are similar objects (nuclear clusters in dwarf galaxies) observed at different stages of their dynamical evolution.