In a meta-analysis of clinical trials, an important issue is whether the treatment benefit varies according to the underlying risk of the patients in the different trials. The usual naive analyses employed to investigate this question use either the observed risk of events in the control groups, or the average risk in the control and treatment groups, as a measure of underlying risk. These analyses are flawed and can produce seriously misleading results. We show how their biases depend on three components of variability, the within-trial and between-trial variances of the control group risks, and the between-trial variance of the treatment effects. We propose a Bayesian solution to the problem which can be carried out using the BUGS implementation of Gibbs sampling. The analysis is illustrated for a meta-analysis of bleeding and mortality data in trials of sclerotherapy for patients with cirrhosis, and the results contrasted with those from the naive approaches. Comparisons with other methods recently proposed for this problem are also made. We conclude that the Bayesian solution presented in this paper is not only more appropriate than other proposed methods, but is also sufficiently easy to implement that it can be used by applied researchers undertaking meta-analyses.