Croatia players react at the end of the World Cup quarterfinal soccer match between Croatia and Brazil, at the Education City Stadium in Al Rayyan, Qatar, Friday, Dec. 9, 2022. AP
Marquinhos missed the crucial spot-kick in the shoot-out, hitting the post when he had to score to keep Brazil in it after Rodrygo's earlier attempt had been saved by goal keeper Dominik Livakovic and Croatia converted all four penalties.
It was a remarkable turnaround after Brazil had looked set for victory when Neymar opened the scoring with a wonderful strike midway through extra time that allowed him to equal Pele's Brazilian record of 77 international goals.
But Bruno Petkovic hit back at the other end in the 117th minute for Croatia to force a shoot-out, and Zlatko Dalic's team followed up their win over Japan on penalties in the last round with this victory, which must go down as their greatest ever triumph.
They advance to the semi-finals, while Brazil will have to wait at least another four years before winning a record-extending sixth title.
Neymar -- who left the pitch in tears -- had fired Brazil into the lead at the end of the first half of extra-time, working one-twos with Rodrygo and Lucas Paqueta before rounding goalkeeper Livakovic to score.
But it did not break Croatia's resistance as the 2018 World Cup finalists hit back to level.
Brazil had never played with the same attacking flair as in their last-16 win over South Korea.
Croatia were as obdurate and difficult to break down as ever, and they have now gone to extra time in eight of their last nine major tournament knockout matches, with the exception being their defeat to France in the World Cup final four years ago.
It was never going to be easy for Brazil to play with the same freedom and joy as in their demolition of South Korea, when they celebrated their goals with choreographed dance moves that seemed to upset some onlookers.
Fear of losing
But the challenge for Brazil coach Tite's side –- given the huge pressure that is always on the Brazilian national team at a World Cup –- was to not let the fear of losing remove all that joy.
The stakes get higher as the tournament progresses and Brazil came into Friday's game at Doha's Education City Stadium looking to avoid falling into another trap set by an accomplished European side.
Brazil had been knocked out of the last four World Cups at either this stage or in the semi-finals, every time by European opposition.
Croatia may be a nation of just four million people but they got to the final four years ago and Luka Modric, their inspiration then, remains one of the finest players on the planet at 37.
It turns out that a midfield three of Modric, Chelsea's Mateo Kovacic and Inter Milan's Marcelo Brozovic can hold its own against Brazil too.
The Selecao had scored four times in the first 36 minutes against South Korea. Here they managed just three attempts on target in the first half, and nothing seriously troubled the Dinamo Zagreb shot-stopper Livakovic.
Brazil nearly scored within two minutes of the second half as an Eder Militao cutback was almost turned into his own by Josko Gvardiol, before Livakovic produced saves from Richarlison, Neymar and Paqueta.
Further Livakovic stops from Neymar and from Paqueta followed, draining some of the belief from a tense Brazilian support.
It seemed as if they were heading for defeat when Neymar broke the deadlock, but Croatia showed all their resilience to equalise when Petkovic applied a first-time finish to a low centre by fellow substitute Mislav Orsic.
Then came penalties, and Nikola Vlasic, Lovro Majer, Modric and Orsic all converted for Croatia, while Rodrygo and Marquinhos came up short.
Neymar, supposed to take Brazil's final kick, did not get the chance, and his tournament ends in tears.
Check the 2022 World Cup matches and statistics.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)