Artifacts caused by patient breathing and movement during PET data acquisition affect image quality. Respiratory gating has been proposed to gate the list-mode PET data into multiple bins over a respiratory cycle. Non-rigid registration of respiratory-gated PET images can reduce the motion artifacts and preserve the count statistics, but it is time consuming. In this work, we propose an unsupervised non-rigid image registration framework using deep learning. We use a differentiable spatial transformer layer to warp the source image to the target image and use a stacked structure for deformation field refinement. Estimated deformation fields were incorporated into an iterative image reconstruction algorithm to perform motion compensated PET image reconstruction. We validated the proposed method using simulation and clinical data and showed its ability to reduce the motion artifact in PET images.