Seydou Doumbia's decisive touch from Borja Garcia's 88th-minute effort undid Antoine Griezmann's inspirational rescue act and handed Diego Simeone's men a heart-breaking exit from a tournament they last won in 2013.
Griezmann, introduced on the hour, had only moments previously completed a quickfire Atletico comeback by lashing them into the lead after helping Angel Correa level the scores inside 90 minutes.
But Girona - who earlier overturned Nikola Kalinic's first-half opener thanks to goals from Valery Fernandez and Cristhian Stuani - recovered to incredibly snatch back the ascendancy as a 4-4 aggregate draw saw them through.
1 - Atletico de Madrid have been knocked out at the last 16 stage of the Copa del Rey for the first time with Diego Simeone as manager. Surprise. pic.twitter.com/H46WL8cAqy— OptaJose (@OptaJose) January 16, 2019
Atleti were in pole position to advance following a 1-1 draw seven days earlier and strengthened their cause through Sevilla-linked Kalinic's composed finish following Diego Godin's long ball in the 12th minute.
The striker had a second ruled out for offside just beyond the half-hour mark and Girona's relief turned to joy as, against the run of play, Fernandez equalised, the teenager controlling a defensive header with his chest and volleying brilliantly across Antonio Adan.
Atleti saw Saul Niguez hobble off after half-time and their hopes of escaping the last 16 appeared in tatters by the 59th minute, the unmarked Stuani heading in Aleix Garcia's free-kick.
Simeone turned to Griezmann and it was his clever poke into the box that enabled Correa to sweep home the equaliser seven minutes later.
Santiago Arias soon became the second Atletico player to have the assistant referee deny him a goal but the home fans' mood swung again in the 84th minute - star man Griezmann gathering Thomas Lemar's inventive pass and rifling into the roof of the net from a tight angle.
It was another substitute, though, who had the final say, Doumbia intelligently flicking in Garcia's shot to decide a rollercoaster contest.
What does it mean? History made for Girona
As the title hopefuls in LaLiga were left to make sense of their first Copa del Rey exit at this stage under Simeone, outsiders Girona will deservedly savour their maiden quarter-final berth as a memorable milestone in an encouraging campaign.
Stuani showcases credentials
Barcelona's search for striking support to Luis Suarez is said to have sparked their interest in the experienced Stuani and he now boasts 13 goals in all competitions this term.
The in-form 32-year-old's thumping header suggested he could provide a point of difference at Camp Nou should the Spanish champions seek to activate his reported €15million release clause.
Simeone pays price for preserving key weapon
Barca last week lost 2-1 at Levante in the Copa del Rey after leaving Lionel Messi out of their squad but Simeone evidently failed to heed that warning as he left Griezmann on the bench until alarm bells were ringing.
Though the France forward had time enough to weave some trademark magic, the assist and goal he registered ultimately served only to highlight the folly in not giving him longer to put the match beyond Girona's grasp.
Atleti, still undefeated inside 90 minutes since October, will refocus on LaLiga when they visit bottom-placed Huesca on Saturday, while Girona can take confidence into a tough away assignment against Real Betis the following day.