I believe it was /ts/ and /dz/ before that, depending on if Old Spanish had ç or z. It's not like it went from [s] to [θ], which I think is what some people assume.
Wikipedia for Old Spanish says there were two distinct variants of z:
The affricates /t͡s̻/ and /d͡z̻/ were simplified to laminodental fricatives /s̻/ and /z̻/, which remained distinct from the apicoalveolar sounds /s̺/ and /z̺/ (a distinction also present in Basque).
That's pretty interesting. I don't have any experience distinguishing between sounds like that but reading around I start to wonder if I might produce such differences without being aware of it.