Compared with conventional computed tomography (CT), dual-energy CT (DECT) provides better material differentiation but requires projection data acquired with two different effective x-ray spectra, limiting DECT applications to specialized scanners. We propose a hardware-based method, known as PM-DECT, which utilizes primary beam modulation to enable single-scan DECT on a conventional CT scanner. PM-DECT inserts an attenuation sheet with a spatially varying pattern-primary beam modulator-between the x-ray source and imaged object. During a CT scan, the modulator selectively hardens the x-ray beam, thereby increasing the average photon energy at specific detector pixel locations. Thus, PM-DECT simultaneously acquires high and low energy data at each projection angle. From the sparse projection data, high and low energy CT images are jointly reconstructed and simultaneously decomposed into basis materials via an iterative CT reconstruction algorithm with gradient weighting and an improved version of similarity based regularization. Studies on Catphan 600 and anthropomorphic head phantoms demonstrate that PM-DECT retains a high level of spatial resolution compared with conventional CT scans. Electron density values calculated from decomposed images indicate a limited error of 1.12% for PM-DECT. Comparison against a two-scan DECT technique shows that PM-DECT's image reconstruction from sparse data sets contributes only 0.66% error. By granting the opportunity for high-quality single-scan DECT on conventional CT scanners via limited hardware modification, PM-DECT has the potential to liberate DECT from specialized scanners, extending clinical availability, and implementation.