Robert Lewandowski's 87th-minute goal gave Borussia Dortmund a winning start to its latest UEFA Champions League campaign.
Mats Hummels' missed second-half penalty looked like being costly for Jurgen Klopp's side in its opening fixture in Group D.
However, Lewandowski struck three minutes from time in front of a crowd of more than 80,000 at the Westfalenstadion.
Dortmund had most of the first-half chances, although none of them were clear-cut.
The game's first opening came in the 10th minute - but Lewandowski's shot was wide of the target.
Two minutes later at the other end Christian Eriksen had a shot which Dortmund goalkeeper Roman Weidenfeller parried for a corner.
The home side's Mario Gotze saw his close-range effort blocked by Ajax goalkeeper Kenneth Vermeer soon after.
Lewandowski tried an ambitious 25-yard lob just before the half-hour mark - but it went over the crossbar - then Marcel Schmelzer brought a save out of Vermeer.
The final chance of the first half came in the 42nd minute but Sebastian Kehl's 30-yard effort sailed over.
The visitor was almost ahead early in the second half but Weidenfeller did brilliantly to parry Siem de Jong's powerfully-struck shot.
Lewandowski shot over before Marco Reus brought a brilliant save out of Vermeer in the 52nd minute.
Then IIkay Gundogan shot over soon after as the home side increased the pressure.
Five minutes later the host had a penalty when Ajax's Ricardo Van Rhijn was penalised for fouling Gotze in the penalty area.
However Hummels' penalty was weakly struck and easily saved by Vermeer.
Ivan Perisic was brought on for Jakub Blaszczykowski for the home side, before Ajax's Ryan Babel was replaced by Lasse Schone with 11 minutes remaining.
The decisive breakthrough came when Lukasz Piszczek headed goalwards and Lewandowski supplied a neat finish into the corner from 12 yards.