Thulani Serero and Danny Hoesen scored to give Ajax a surprise halftime lead, but straight after the break defender Joel Veltman was red-carded for a tackle on Neymar and Xavi pulled a goal back from the penalty spot.
Injury-plagued Barcelona, who had already qualified for the knockout stages from Group H, applied pressure in search of an equaliser but Ajax held out to wild applause in Amsterdam Arena.
“I said Ajax would be the first team to beat Barcelona with the football we always want to play, which is attacking football,” said Ajax manager Frank de Boer.
“After the sending-off it became difficult and dangerous but we showed our lion’s heart.”
Ajax stay third in the group, one point behind AC Milan, who they must now beat away on December 11 to qualify.
“We had a good feeling before the game and that’s why we started well. We were playing probably the best team in the world, so what did we have to lose?” Hoesen told reporters.
Barcelona, without the injured Lionel Messi, are two points clear and not yet sure of top place.
Barca coach Gerardo Martino said: “In the first half we didnt have a good attitude. At an individual level we were not as good as Ajax.”
Serero ghosted in late for the first goal in the 19th minute, applying the decisive touch to a strong cross from the right from fullback Ricardo van Rhijn, who just five minutes earlier had made a goal-saving tackle on Neymar.
The South Africa international’s first Champions League goal precipitated a period of sustained pressure from the young Dutch side, culminating in a second goal three minutes from halftime.
A poor clearance by Javier Mascherano allowed Ajax to set up a chance for Viktor Fischer, whose shot was parried by goalkeeper Jose Manuel Pinto, only for Hoesen to pick up the rebound, go round Carles Puyol and score with the help of a deflection off Gerard Pique.
An Ajax fan was seriously injured after falling 10 metres from the stands as he celebrated the goal. He was taken to hospital.
But the comfortable cushion deflated just two minutes after the break when Van Rhijn’s poor back pass sent Neymar away and Veltman tripped him on the edge of the area, conceding a penalty and getting himself sent off.
Xavi converted the spot kick to send Ajax into defensive mode. They tigerishly kept Neymar at bay and ensured the Brazilian has yet to open his Champions League scoring account.
“We knew we had to be compact and keep playing after the penalty. It was a silly mistake,” said Serero.
It was Barcelona’s first defeat under new coach Martino and ended hopes of a record-equalling, longest unbeaten start to a season.
The Spanish club had gone 20 games without defeat, one shy of the record set by Pep Guardiola’s 2011-12 side. They last lost at home to Bayern Munich in last season’s Champions League semifinal.