Diego Simeone's men trailed 2-1 heading into the last-16 second leg tie against their city rivals at the Wanda Metropolitano on Wednesday night.
Los Blancos edged out the first leg at the Bernabeu last week thanks to goals from Rodrygo and Braham Diaz either side of Julian Alvarez's equaliser.
But with just 27 seconds on the clock in the return fixture, Gallagher fired the hosts ahead from close range.
The ex-Chelsea man capitalised on a loose ball to poke past Thibaut Courtois to spark wild celebrations.
It's the quickest goal ever scored by an Englishman in Europe's premier competition.
READ MORE ON CHAMPIONS LEAGUE
'Better with age' - Harry Kane makes Champions League history after hitting landmark
Unseen footage shows Virgil van Dijk talking to PSG chiefs after Liverpool exit
And incredibly, it's the 25-year-old's first ever goal in Europe.
In another record Gallagher has set, his strike is the quickest Champions League goal in Atletico's history.
But the England international's goal was no match for Roy Makaay's rapid strike for Bayern Munich in March 2007.
That goal coincidentally was also against Real in a last-16 second leg - with Makaay finding the back of the net in 10.12 seconds.
Most read in Champions League
Jamie Carragher leaves CBS Sports studio midway through Champions League coverage
Arsenal and Villa through, Gallagher record-breaking goal takes Real Madrid to extra time
Ex-PSG stars 'kicked out' of Anfield during Liverpool Champions League win
Mo Salah fights back tears after Champions League exit as fans fear the worst
And Gallagher will be hoping his goal will prove to be a lucky omen with Bayern losing the first leg to Real - just like Atletico.
The Bavarian outfit managed to advance into the quarter-finals after winning the second leg, before exiting at the quarter-final stage.
Gallagher has enjoyed a fine opening season in Spain so far since joining from the Blues last summer for £36million.
In what is his 36th outing for Atletico, he now has chipped in with three goals and four assists in all competitions.
Prior to the second leg against Real, Gallagher hadn't been on the score sheet since September 22.
But it's his workrate and relentless energy that is what Simeone is seeking.
And that was certainly evident by the Argentine's reaction to the midfielder's last-ditch tackle in the 1-0 over Athletic Bilbao earlier this month.
Having scooped the club's September Player of the Month award, Gallagher could be in line to win their March gong if his goal helps send Atletico in the next stage of the Champions League.
Bizarre reason why Conor Gallagher was filmed singing Ed Sheeran classic for Atletico Madrid