A computer assisted pH-metric investigation has been carried out on the speciation of complexes of Pb(II), Cd(II) and Hg(II) with l-phenylalanine and maleic acid. The titrations were performed in the presence of different relative concentrations (M:L:X = 1.0:2.5:2.5; 1.0:2.5:5.0; 1.0:5.0:2.5) of metal (M) to l-phenylalanine (L) and maleic acid (X) with sodium hydroxide in varying concentrations (0.0–2.5 % w/v) of sodium dodecyl sulfate (SDS)–water mixtures at an ionic strength of 0.16 mol l−1 and at a temperature of 303.0 K. Stability constants of the ternary complexes were refined using MINIQUAD75. The species MLXH2, ML2XH2 and ML2XH for Pb(II) and MLX2H3, ML2XH2 and ML2XH for Cd(II) and ML2XH2, ML2XH and MLX2 for Hg(II) were detected. The extra stability of ternary complexes compared to their binary complexes was believed to be due to electrostatic interactions of the side chains of ligands, charge neutralisation, chelate effect, stacking interactions and hydrogen bonding. The species distribution with pH at different compositions of SDS–water mixtures and plausible equilibria for the formation of species were also presented.