Use an artificial system of locks, weirs and dams to control the flow of the river. When the water level is too low, close the downstream gates so the river backs up. When the water level is too high, close the upstream gates so it empties.
In order to be able to deal with droughts or downpour, you will of course need some room to store excess water upstream (a natural lake, artificial reservoir, floodplain or a section of river flowing through a deep valley) and to drain water downstream (like a larger river or ocean).
You see systems like this in many cities which have rivers flowing through them. Let's take the river Alster which flows through the city of Hamburg in northern Germany, for example. The river flows through two artificial lakes in the center of the city. Those lakes have a nearly constant water level all year around. How do they do this? With a system of variable weirs along the 50km upstream which meticulousmeticulously control the inflow and a set of locks which control the outflow into the larger Elbe river (as well as prevent inflow from the Elbe when it has high tide). The system was built over 400 years ago, so you don't need 20th century technology to achieve that level of water flow control (although modern meteorology and electronic communication do of course help to improve the reliability). There is a German wikipedia article about the Alster lock system with lots of pictures.