Image reconstruction and motion model estimation in four dimensional cone-beam CT (4D-CBCT) are handled as two sequential steps conventionally. Due to the limited number of projections at each phase, the image quality of 4D-CBCT is degraded by the view-aliasing artifacts and the accuracy of subsequent motion modeling is decreased by inferior 4D-CBCT. The objective of this work is to enhance both the image quality of 4D-CBCT and the accuracy of motion model estimation through developing a novel strategy enabling Simultaneous Motion Estimation and Image Reconstruction (SMEIR). The proposed SMEIR algorithm consists of two alternating steps: 1) model-based iterative image reconstruction to obtain motion-compensated primary CBCT (m-pCBCT) and 2) motion model estimation through an unconstraint optimization to obtain an optimal set of deformation vector fields (DVF) between m-pCBCT and other phases of 4D-CBCT. The motion-compensated image reconstruction is based on the simultaneous algebraic reconstruction (SART) technique coupled with the total variation regularization. During the forward- and back-projection of SART, measured projections from an entire set of 4D-CBCT are used for the reconstruction of m-pCBCT by utilizing the updated DVF. The DVF is estimated by matching the forward projection of the deformed m-pCBCT and measured projections of other phases of 4D-CBCT. The performance of SMEIR algorithm is quantitatively evaluated on a 4D NCAT phantom and a lung cancer patient. Image quality of 4D-CBCT is substantially improved by SMEIR algorithm in both phantom and patient studies. The accuracy of tumor motion trajectory estimation in SMEIR is also greatly improved as compared to those resulted from conventional sequential 4D-CBCT reconstructions (FDK and total variation minimization) and motion estimation (Demons) algorithm. The SMEIR algorithm provides a valuable tool for the treatment of moving tumors in radiation therapy.