Bunyan began his work while in the Bedfordshire county prison for violations of the Conventicle Act of 1664, which prohibited the holding of religious services outside the auspices of the established Church of England. Early Bunyan scholars such as John Brown believed The Pilgrim's Progress was begun in Bunyan's second, shorter imprisonment for six months in 1675, but more recent scholars such as Roger Sharrock believe that it was begun during Bunyan's initial, more lengthy imprisonment from 1660 to 1672 right after he had written his spiritual autobiography Grace Abounding to the Chief of Sinners.
The English text comprises 108,260 words and is divided into two parts, each reading as a continuous narrative with no chapter divisions. The first part was completed in 1677 and entered into the Stationers' Register on 22 December 1677. It was licensed and entered in the "Term Catalogue" on 18 February 1678, which is looked upon as the date of first publication. After the first edition of the first part in 1678, an expanded edition, with additions written after Bunyan was freed, appeared in 1679. The Second Part appeared in 1684. There were eleven editions of the first part in John Bunyan's lifetime, published in successive years from 1678 to 1685 and in 1688, and there were two editions of the second part, published in 1684 and 1686.