We demonstrate a technique to simultaneously stabilize the frequency and output power of a terahertz quantum-cascade laser (QCL). This technique exploits frequency and power variations upon near-infrared illumination of the QCL with a diode laser. It does not require an external terahertz optical modulator. By locking the frequency to a molecular absorption line, we obtain a long-term (one-hour) linewidth of 260 kHz (full width at half maximum) and a root-mean-square power stability below 0.03%. With respect to the free-running case, this stabilization scheme improves the frequency stability by nearly two orders of magnitude and the power stability by a factor of three.