Task-space inverse dynamics is a versatile paradigm for real-time robot control, capable of handling under-actuation and contact interactions across diverse platforms from humanoids to deformable robots. However, in practice, contact-aware controllers typically assume predefined contact sequences, inherently limiting their ability to automatically select among breaking, sliding, or sticking contacts. In this work, we extend the classical quadratic programming formulation of inverse dynamics to a quadratic program with complementarity constraints (QPCC). This formulation natively accounts for actuator limits and frictional contacts, modeled as nonlinear complementarity constraints. To solve these QPCC problems, we propose an iterative optimization approach based on alternating minimization and augmented Lagrangian methods. Our solver alternates between minimizing a smooth, convex function that captures task objectives and system dynamics, and projecting onto sets that enforce actuator and nonconvex frictional contact constraints. By handling complementarity constraints through projection, our approach implicitly and automatically reasons about optimal contact modes. We demonstrate the efficiency and versatility of our approach across various scenarios, ranging from dynamic jumping and contact-rich motions with rigid robots to complex environmental interactions with soft robots.