We have developed a new model for analysing light curves of planetary transits when there are starspots on the stellar disc. Because the parameter space contains a profusion of local minima we developed a new optimisation algorithm which combines the global minimisation power of a genetic algorithm and the Bayesian statistical analysis of the Markov chain. With these tools we modelled three transit light curves of WASP-19. Two light curves were obtained on consecutive nights and contain anomalies which we confirm as being due to the same spot. Using these data we measure the star's rotation period and velocity to be 11.76 ± 0.09 d and 3.88 ± 0.15 kms−1, respectively, at a latitude of 65°. We find that the sky-projected angle between the stellar spin axis and the planetary orbital axis is λ = 1.0° ± 1.2°, indicating axial alignment. Our results are consistent with and more precise than published spectroscopic measurements of the Rossiter-McLaughlin effect.