The use of randomization for assigning patients to treatment groups in clinical trials is firmly acknowledged as providing the best quality results. Two standard methods are used in order to achieve well-balanced groups with respect to prognostic factors (i.e. factors influencing the disease outcome): stratification and minimization. Stratification is recommended when the number of strata is not too high--otherwise, minimization is preferred. However, minimization may compromise blinding (since the search for balance is performed a priori) and, furthermore, use of the technique has been questioned by the European Agency for the Evaluation of Medicinal Products. We have developed a new procedure for adaptive randomization, which we have named 'randomization with a posteriori constraints'. By using a search for balance a posteriori, this procedure ensures that patient groups are similar with respect to prognostic factors while being less vulnerable to selection bias. The aim of this work was to describe the new method and to compare it (using simulations) with stratification and minimization. In the case of trials with few prognostic factors, the recourse to minimization or 'randomization with a posteriori constraints' does not appear to be useful. In such a context, stratification has suitable properties and its simplicity of implementation encourages its use. However, when the number of prognostic factors is higher, 'randomization with a posteriori constraints' is less predictable than minimization and the chance of imbalance is lower than for stratification. In conclusion, 'randomization with a posteriori constraints' with an adequate threshold seems to be a good compromise between minimization and stratification.