We present a novel approach for the generation of higly frequency-stable, widely tunable, single-frequency cw UV light that is suitable for high-resolution spectroscopy. Sum-frequency generation (SFG) of two solid-state sources with a single cavity resonant for both fundamental waves is employed. Using a highly stable, narrow-linewidth frequency-doubled cw Nd:YAG laser as a master laser and slaving to it the SFG cavity and the other fundamental wave from a Ti:sapphire laser, we generate UV radiation of 33-mW output power around 313 nm. Alternatively, we use a diode laser instead of the Ti:sapphire laser and produce an output power of 2.1 mW at 313 nm. With both setups we obtain a continuous tunability of >15 GHz, short-term frequency fluctuations in the submegahertz range, a long-term frequency drift below 100 MHz/h, and stable operation for several hours. The theory of optimized doubly resonant SFG is also given.