We report a surface-emitting THz source based on intracavity difference-frequency generation in dual-wavelength midinfrared quantum cascade lasers with integrated giant second-order nonlinear susceptibility. The THz light is coupled out of the waveguide by a second-order grating etched into the laser ridges. In contrast to sources where the difference-frequency radiation is emitted from the facet, this approach enables extraction of the THz emission from the whole length of the device even when the coherence length is small. We also studied the properties of the mid-infrared pump beams and found that due to gain competition, mid-infrared modes tend to start lasing in higher order lateral modes. The mid-infrared mode with the lower threshold current reduces population inversion for the second laser with the higher threshold current due to stimulated emission. We developed a rate equation model to quantitatively describe mode interactions due to mutual gain depletion.