A frantic start at the Khalifa International Stadium saw Croatia take the lead in just the 7th minute through a diving header from defender Josko Gvardiol that capped off a cleverly worked free kick routine.
It took Morocco all of two minutes to level matters with a headed goal of their own from defender Achraf Dari.
Mislav Orsic put Croatia ahead minutes before the break, curling in a majestic strike from the left side of the box.
Both sides had several attempts in the second period, but Orsic's stunner proved to be the game's winning goal.
This was Croatia's second third-place finish at the World Cup, repeating their feat from 1998, and follows a remarkable 2018 campaign that saw them finish as runners-up to France.