We have studied two-photon nonlinear optical effects arising in a microcavity geometry from resonant two-photon absorption or second-harmonic generation. The transmission spectrum of the cavity is shown to depend on light intensity according to a simple two-level picture with an intensity-dependent coupling: at resonance the system exhibits a two-photon Rabi splitting. The absorption spectrum of a weak probe beam in a pumped cavity is found to strongly depend on pump intensity and detuning; the resulting effect is a sort of two-photon analogue of the usual optical Stark effect. For moderate pump intensities a two-level picture with a pump-dependent coupling can account for the main results, while at higher intensities new unexpected features show up; in particular, we predict the appearance of gain in well-determined spectral regions due to hyper-Raman processes. Finally, we have shown how the coupling coefficients appearing in our formalism can be obtained from a detailed knowledge of the material and geometrical properties of a specific system. For illustrative purposes, we have estimated the required light intensities using realistic data for a GaAs-based semiconductor microcavity. ͓S0163-1829͑99͒00932-7͔