Bunyan started to write the book in jail. He got into trouble for preaching without a licence. Bunyan, who was a Reformed Baptist, did not qualify for a licence. Only ministers of the Church of England were allowed to preach. He spent 12 years in Bedford jail. He might have been freed if he had promised not to preach, but he refused. He was let out only when the law changed, in 1672. He was jailed again for a short time in 1677.