The ceceo—pronouncing z and c (before e/i) as a voiceless dental fricative /θ/ (like English "th")—is a hallmark of Peninsular Spanish, especially central and northern Spain.
During the Middle Ages, Old Spanish had several sibilant sounds that gradually merged and shifted. A key hypothesis links the /θ/ outcome to Arabic influence during the centuries of Al-Andalus (711–1492). Arabic has the phoneme /θ/ (written ث), and extensive bilingualism in medieval Iberia may have facilitated its adoption into the evolving Romance varieties of the north.
Ceceo dominates in Castile and surrounding regions. Seseo (merging /θ/ and /s/ into /s/) prevails in Andalusia, Canary Islands, and all of Latin America—due to southern Spanish settlers carrying seseo to the New World.
Thus, the "th" sound is a medieval Castilian innovation, possibly reinforced by Arabic contact, that became the prestige norm in central Spain.