The term comes from English cricket in the 1850s — a bowler who took three wickets in three balls was awarded a new hat by the club. It crossed into football by the 1870s and stuck. To count, all three goals must be scored within ninety minutes plus stoppage; goals in extra time are usually credited together with regulation goals when the match is in the World Cup. Penalties count. Own goals do not.
Variations matter. A perfect hat-trick is one goal with the left foot, one with the right, and one with the head — extremely rare at the international level. A natural hat-trick is three consecutive goals without another player scoring in between. Match balls are presented to the scorer at the final whistle, even if the team lost; cabinets full of game-used balls are a quiet privilege of elite forwards.
World Cup hat-tricks are uncommon. Geoff Hurst scored the only one in a final, in 1966 for England against West Germany, and the list of all hat-trick scorers in the tournament's history is short enough to fit on one page.