Substitute Ferran Torres scored the winner in the 106th minute.
Spain dominated for long spells and had the better of the chances, but goalkeeper Emiliano Martinez kept Argentina in the game with a string of saves.
Argentina were reduced to ten men in stoppage time when Enzo Fernandez was sent off for a second yellow card, but held out until Torres struck following a header down from Inaki Williams.
A second Torres goal was ruled out for offside soon after.
It's Spain's first World Cup win since 2010, when they also won 1-0 in extra time, that time against the Netherlands.
The victory extended their unbeaten run to 38 matches, a new record.
The final was watched by a crowd of over 80,000, including US President Donald Trump, who presented the trophy alongside FIFA president Gianni Infantino.
A host of celebrities attended, among them Poland captain Robert Lewandowski, and the half-time show featured performances from Shakira and Justin Bieber.
The 2026 tournament, jointly hosted by the United States, Canada and Mexico, was the first to feature 48 teams and ran for a record 39 days.
The next World Cup will be held in 2030 in Spain, Portugal and Morocco, with the opening three matches played in Uruguay, Argentina and Paraguay to mark the centenary of the first tournament.
(ał)
Source: PAP
Click on the audio player above for a report by Piotr Urbaniak.