We derive a general and exact equation of motion for a quantized vortex in an inhomogeneous two-dimensional Bose-Einstein condensate. This equation expresses the velocity of a vortex as a sum of local ambient density and phase gradients in the vicinity of the vortex. We perform Gross-Pitaevskii simulations of single-vortex dynamics in both harmonic and hard-walled disk-shaped traps, and find excellent agreement in both cases with our analytical prediction. The simulations reveal that, in a harmonic trap, the main contribution to the vortex velocity is an induced ambient phase gradient, a finding that contradicts the commonly quoted result that the local density gradient is the only relevant effect in this scenario. We use our analytical vortex velocity formula to derive a point-vortex model that accounts for both density and phase contributions to the vortex velocity, suitable for use in inhomogeneous condensates. Although good agreement is obtained between Gross-Pitaevskii and point-vortex simulations for specific few-vortex configurations, the effects of nonuniform condensate density are in general highly nontrivial, and are thus difficult to efficiently and accurately model using a simplified point-vortex description.