Jesse Marsch's side were in deep trouble when Jonny and Francisco Trincao netted to put Wolves in control by half-time at Molineux.
But Wolves striker Raul Jimenez was sent off for crunching into Leeds keeper Illan Meslier early in the second half.
Leeds made the most of that lucky break as Jack Harrison and Rodrigo netted to draw them level before Ayling won it in stoppage-time.
It was a second successive late victory for Leeds, who beat relegation rivals Norwich in the final seconds last weekend.
Leeds are now seven points clear of the relegation zone, with third bottom Watford holding a game in hand.
The Yorkshire club aren't safe yet, but former Leipzig boss Marsch has given them hope since replacing Marcelo Bielsa in February.
They showed their fighting spirit not only in the comeback but also after losing four players in injuries.
Wolves suffered a major setback themselves early on when in-form Portugal midfielder Ruben Neves was forced off.
But Leeds were bitten by the injury bug moments later as Patrick Bamford went down holding his leg, prematurely ending just his fourth appearance since September.
There was worse to come for Leeds as Wolves took the lead in the 26th minute as Jonny met Trincao's cross with a clinical finish from 12 yards to claim his first goal since 2020.
As if that wasn't bad enough, Leeds also saw Diego Llorente limp off injured, with his team-mate Mateusz Klich forced from the game with a concussion before half-time.
Wolves scented blood and Trincao was inches away with a long-range blast that cannoned back off the post.
Meslier made a superb save to deny Jonny, but Wolves struck again 11 minutes into first half stoppage-time.
Wolves caught Leeds out with a quick free-kick and Daniel Podence cut his pass back to Trincao, who adjusted nimbly to drive a low strike past Meslier from the edge of the area.
Incredibly, Leeds sustained yet another serious injury in the 53rd minute when Meslier sprinted out of his area to challenge Jimenez, causing a fierce collision that left both players writing in agony.
Meslier was unable to continue, with Leeds allowed a fourth substitute due to the concussion rule over Klich's exit.
But Jimenez followed Meslier down the tunnel after being dismissed for his aggressive tackle in what proved the game's turning point.
Leeds made the most of their numerical superiority to reduce the deficit in the 64th minute.
Ayling hit the post and then saw his follow-up cleared off the line by Conor Coady, but Harrison pounced on the rebound to slot home.
Wolves' defence was creaking badly and just three minutes later Rodrigo made them pay, the Spanish forward poking in the equaliser after Dan James hit the woodwork.
Leeds completed their astonishing comeback in stoppage-time when Wolves failed to clear a free-kick and Ayling lashed in to spark wild celebrations.
Even then the drama wasn't over and only a brilliant save from substitute keeper Kristoffer Klaesson denied Trincao an equaliser.