Generation of terahertz (THz) radiation in the interaction of laser pulse with intensity ∼5 × 1018 W cm−2 with a controlled preplasma, created by an additional laser pulse interacting with a 16 μm film target, was studied. The mechanism of generation of THz radiation in the frequency range 1–5 THz was found to be coherent transition radiation of accelerated electrons transversing the rear plasma-vacuum boundary. Angular distribution of the THz radiation changes with the delay between main pulse and prepulse due to different regimes of electron acceleration, while THz radiation spectrum reflects the spatial size of the preplasma cloud and may be used for diagnostics purposes. THz radiation energy reaches ∼0.1 mJ in 1–5 THz spectral range, corresponding to 0.2% conversion efficiency, and increases linearly with laser pulse energy.