Let $X$ be a space of homogeneous type and let $L$ be a nonnegative self-adjoint operator on $L^2(X)$ which satisfies a Gaussian estimate on its heat kernel. In this paper we prove a Homander type spectral multiplier theorem for $L$ on the Besov and Triebel--Lizorkin spaces associated to $L$. Our work not only recovers the boundedness of the spectral multipliers on $L^p$ spaces and Hardy spaces associated to $L$, but also is the first one which proves the boundedness of a general spectral theorem on Besov and Triebel--Lizorkin spaces.