Abstract To assimilate water level data into numerical shallow water flow models Kalman filtering and model fitting can be employed. An advantage of Kalman filtering is its stochastic nature. By introducing a system noise process into the system equations it is possible to take into account the inaccuracies of the underlying deterministic system. However, Kalman filtering can only be employed for linear or weakly nonlinear problems. Model fitting is more suitable for nonlinear problems but it is a deterministic method. To combine the best of both approaches, a data assimilation procedure based on stochastic optimal control theory has been developed. The new approach is applied to assimilate water level data into a storm surge prediction model.