An enhanced inverse dynamics approach is here presented for feedforward control of underactuated multibody systems, such as mechanisms or robots where the number of independent actuators is smaller than the number of degrees of freedom. The method exploits the concept of partitioning the independent coordinates into actuated and unactuated ones (through a QR-decomposition) and of linearly combined output, to obtain the internal dynamics of the nonminimum-phase system and then to stabilize it through proper output redefinition. Then, the exact algebraic model of the actuated sub-system is inverted, leading to the desired control forces with just minor approximations and no need for pre-actuation. The effectiveness of the proposed approach is assessed by three numerical test cases, by comparing it with some meaningful benchmarks taken from the literature. Finally, experimental verification through an underactuated robotic arm with two degrees of freedom is performed.