This study examines pairs trading using a general state space model framework. It models the spread between the prices of two assets as an unobservable state variable assuming that it follows a mean-reverting process. This new model has two distinctive features: the (1) non-Gaussianity and heteroscedasticity of innovations to the spread, and (2) nonlinearity of the mean reversion of the spread. It shows how to use the filtered spread as the trading indicator in carrying out statistical arbitrage and proposes a new trading strategy which uses a Monte Carlo-based approach to selecting the optimal trading rule. The new model and trading strategy are illustrated by two examples: PEP vs. KO and EWT vs. EWH. The empirical results show that the new approach can achieve 21.86% (31.84%) annualized return for the PEP-KO (EWT-EWH) pair. Then all the possible pairs among the five largest and the five smallest U.S. banks listed on the NYSE are considered. For these pairs, the performance of the proposed approach with that of the existing popular approaches, are compared both in-sample and out-of-sample. In almost all the cases considered, our approach can significantly improve the return and the Sharpe ratio.