The stabilization of Port-Controlled Hamiltonian (PCH) systems under exogenous disturbances by designing a compensation control approach is studied in the paper. Firstly, a baseline feedback control is proposed utilizing the damping injection method. To estimate disturbances, then a novel exogenous disturbance observer is constructed, based on which a feedforward compensation control is developed. Next, a composite control law is proposed based on the feedforward compensation and the feedback control. For the Hamiltonian system, an asymptotic stability analysis is followed finally. The feasibility of the compensation control strategy is revealed by a numerical simulation example.