The moving horizon estimation (MHE) problem is investigated in this paper for a class of networked systems with packet dropouts. The packet dropout is described by a binary switching random sequence. The main purpose of this paper is to design a estimator such that, for all possible packet dropouts, the state estimation error sequence is convergent. By choosing a stochastic cost function, the optimal solution of the MHE optimization problem with packet dropouts is given. Moreover, the convergence properties of the estimator are studied, and the maximum packet dropout probability is given to ensure the convergence of the state estimation error. Finally, the performance of the proposed estimator is evaluated and an example is given to demonstrate the effectiveness of the proposed method.