In randomized trials, researchers are often interested in mediation analysis to understand how a treatment works, in particular how much of a treatment’s effect is mediated by an intermediated variable and how much the treatment directly affects the outcome not through the intermediate variable. The standard regression approach to mediation analysis assumes sequential ignorability of the mediator, that is that the mediator is effectively randomly assigned given baseline covariates and the randomized treatment. Since the experiment does not randomize the mediator, sequential ignorability is often not plausible. Ten Have et al. (2007, Biometrics), Dunn and Bentall (2007, Statistics in Medicine) and Albert (2008, Statistics in Medicine) presented methods that use baseline covariates interacted with random assignment as instrumental variables, and do not require sequential ignorability. We make two contributions to this approach. First, in previous work on the instrumental variable approach, it has been assumed that the direct effect of treatment and the effect of the mediator are constant across subjects; we allow for variation in effects across subjects and show what assumptions are needed to obtain consistent estimates for this setting. Second, we develop a method of sensitivity analysis for violations of the key assumption that the direct effect of the treatment and the effect of the mediator do not depend on the baseline covariates.