For head x-ray CT imaging, the head needs to remain motionless during the scan. In clinical practice, however, head motion is sometimes unavoidable depending on the patient. The motion can occur abruptly during the scan and can be unpredictable. It thereby causes motion artifacts such as tissue blurring or doubled edges around the skull area. To mitigate this problem, we propose a 3D head motion estimation (ME) and compensation algorithm based on filtered backprojection. If a patient moves his or her head during the scan, a motion-corrupted sinogram is obtained. Modeling the head motion as a 3D rigid transformation, we develop a motion-compensated (MC) reconstruction algorithm based on the FDK algorithm. To determine the head motion of a rigid transformation, we propose two optimization-based ME schemes depending on the degree of head motion, both of which are performed by updating motion parameters and the corresponding MC reconstructed image alternatively until the proposed cost function is minimized for the MC reconstructed image. In particular, to improve the robustness in the case of large motion, we propose attaching a fiducial marker to the head so that more reliable motion parameters can be initialized by determining the marker position, before the optimization. To evaluate the proposed algorithm, a numerical phantom with realistic, continuous, and smoothly varying motion, and a moving physical phantom are used with a gantry rotation time of 1s. In the simulation using a numerical phantom and in the experiment using a physical phantom, the proposed algorithm provides well-restored 3D motion-compensated images in both cases of small and large motion. In particular, in the case of large motion of the physical phantom, using a fiducial marker, we obtain remarkable improvement of image quality in cerebral arteries and a lesion as well as the skull. Quantitative evaluations using the image sharpness and root-mean-square error also show noticeable improvement of image quality in both simulations and experiments. We propose a framework for head motion correction in an axial CT scan, which consists of motion estimation and compensation steps. Two image-based ME algorithms for rigid motion tracking are developed according to the degree of head motion. The estimated motion information is then used for MC image reconstruction. Both motion estimation and compensation algorithms are based on computationally efficient filtered backprojection. Excellent performance of the proposed framework is illustrated by means of simulations using a numerical phantom and experiments using a physical phantom.