It was a spectacular reversal as Brazil appeared to be heading for victory when Neymar opened the score midway through extra time, matching Pele's Brazilian record of 77 international goals.
Croatia stunned Brazil on Friday, winning 4-2 on penalties after a nailbiting last-eight tie ended 1-1 at the end of extra time. Marquinhos missed the crucial spot-kick in the shoot-out, hitting the post when he needed to score to keep Brazil in it after Rodrygo's earlier attempt was saved by goalkeeper Dominik Livakovic, and Croatia converted all four penalties. It was a spectacular reversal as Brazil appeared to be heading for victory when Neymar opened the score midway through extra time, matching Pele's Brazilian record of 77 international goals.
But, in the 117th minute, Bruno Petkovic equalised for Croatia, forcing a shootout, and Zlatko Dalic's squad followed up their success over Japan on penalties in the previous round with this victory, which must go down as their greatest ever triumph.
They proceed to the semi-finals, but Brazil will have to wait at least four years for a record-tying sixth triumph.
Neymar had given Brazil the lead at the conclusion of the first half of extra time, combining with Rodrygo and Lucas Paqueta before past goalie Livakovic to score.
It did not, however, shatter Croatia's resilience, as the 2018 World Cup finalists equalised.
Brazil had never played with such attacking flair as they did in their last-16 victory against South Korea.
Croatia remained obstinate and tough to break down, and they have now gone to extra time in eight of their previous nine major tournament knockout matches, with the exception of their World Cup final defeat to France four years ago.
Brazil was never going to be able to play with the same freedom and delight that they did in their thrashing of South Korea, when they celebrated their goals with rehearsed dance routines that seemed to irritate some viewers.
But, considering the enormous expectation that is usually placed on the Brazilian national team during a World Cup, the task for Brazil coach Tite's side was to not allow the dread of losing take away all of that joy.
The stakes rise as the tournament advances, and Brazil entered Friday's encounter at Doha's Education City Stadium hoping to avoid another trap set by an experienced European squad.
Brazil had been eliminated from the previous four World Cups at this point or in the semi-finals by European opponents.
Croatia, a country of only four million people, reached the final four years ago, and their inspiration at the time, Luka Modric, is still one of the best players on the planet at 37.
It turns out that a midfield trio consisting of Modric, Chelsea's Mateo Kovacic, and Inter Milan's Marcelo Brozovic can compete with Brazil as well.
Brazil scored four goals against South Korea in the opening 36 minutes.
In the first half, they only had three shots on goal, and nothing significantly bothered Dinamo Zagreb shot-stopper Livakovic.
Brazil nearly scored two minutes into the second half after an Eder Militao cutback was almost converted into his own by Josko Gvardiol, but Livakovic saved Richarlison, Neymar, and Paqueta.
Further Livakovic stops came from Neymar and Paqueta, draining some of the belief from a tense Brazilian crowd.
When Neymar opened the scoring, Croatia appeared to be on the verge of loss, but Petkovic equalised with a first-time finish to a low centre by fellow replacement Mislav Orsic.
Then followed penalties, which Croatia won thanks to Nikola Vlasic, Lovro Majer, Modric, and Orsic, while Rodrygo and Marquinhos failed to convert.
Neymar, who was meant to take Brazil's last kick, was unable to do so, and his tournament came to an end in tears.