New radiobiological models are used to describe tumour and normal tissue reactions and to account for their dependence on the irradiated volume and inhomogeneities of the delivered dose distribution and cell sensitivity. The probability of accomplishing complication-free tumour control is maximized by an iterative algorithm. The algorithm is demonstrated by applying it to a one-dimensional (1D) tumour model but also to a more clinically relevant 2D case. The new algorithm is n-dimensional so it could simultaneously optimize the dose delivery in a 3D volume and in principle also select the ideal beam orientations, beam modalities (photons, electrons, neutrons, etc) and optimal spectral distributions of the corresponding modalities. To make calculation time reasonable, 2D-3D problems are most practical, and suitable beam orientations are preselected by the choice of irradiation kernel. The energy deposition kernel should therefore be selected in order to avoid irradiation through organs at risk. Clinically established dose response parameters for the tissues of interest are used to make the optimization as relevant as possible to the clinical problems at hand. The algorithm can be used even with a poorly selected kernel because it will always, as far as possible, avoid irradiating organs at risk. The generated dose distribution will be optimal with respect to the spatial distribution and assumed radiobiological properties of the tumour and normal tissues at risk for the kernel chosen. More specifically the probability of achieving tumour control without fatal complications in normal tissues is maximized. In the clinical examples a reduced tumour dose is seen at the border to sensitive organs at risk, but instead an increased dose just inside the tumour border is generated. The increased tumour dose has the effect that the dose fall-off is as steep as possible at the border to organs at risk.