We developed a 4D SPECT image reconstruction method with respiratory motion (RM) and cardiac motion (CM) compensation, and evaluated its performance using a previously developed 4D channelized Hotelling observer (CHO) model for the task based evaluation of 4D medical images. A series of 4D XCAT (eXtended CArdiac Torso) phantoms with and without a regional CM abnormality was generated that divided a respiratory cycle into 24 frames and a cardiac cycle into 48 frames for each respiratory phase. Almost noise-free projection data were generated from the 1152 3D XCAT phantoms at each respiratory and cardiac (R&C) gated time frame using the SimSET simulation modeling a typical 99mTc Sestamibi gated myocardial perfusion (GMP) SPECT study. They were scaled and combined to form 6 equal-amplitude respiratory gates and 8 equal-time cardiac gates. Poisson noise was then added before image reconstruction using the 3D OS-EM with or without RM and CM compensation. Using a group-wise B-spline non-rigid image-based registration method, the deformation field (DF) of the RM were estimated and applied to each cardiac phase of the R&C gated SPECT images for RM correction. Then, the RM compensated GMP SPECT images were transformed using the estimated DF of the CM. The 2D reconstructed image slices were extracted and reorganized into a set of cine images and the space-time channels of the 4D CHO were applied to produce the space-time feature vectors to which the receiver operating characteristic (ROC) was applied and areas under the ROC curve (AUC) values calculated. The result demonstrated that the RM and CM compensated images showed drastically reduced noise level without blurring and its AUC values were significantly higher than those without compensation. We conclude that the RM and CM compensation allow significant reduction of image blurring and noise level in dual gated SPECT images resulting in significant improvement in detecting a regional CM abnormality using a 4D CHO model.