They did it by:
Inducing the Persians to believe that the Greek fleet oud flee the battle and escape through the passage between Salamis and Megara, so the Persians sent off a third of their fleet to cover this.
Remaining within the enclised waters off Salamis, which required the remaining Persian fleet to enter around both sides of the island of Psytallia, which further split the fleet and made it adopt a line ahead formation.
They then fell on the lines rom the flank, concentrating their force against a dispersed enemy.
Thus the originally superior Persian fleet had a third taken out of the battle, was caught in an inferior line of battle, and attacked from the flanks with numerical superiority. Its heavier ships were negated by the close engagement in enclosed waters. The odds were well and truly turned in favour of the Greek fleet.