He was warned that if he persisted in disobeying the law he would be liable to banishment, and that if he were found in England after a certain time his neck would be stretched. His answer was, "If you let me out to-day, I will preach again to-morrow." Year after year he lay patiently in a dungeon, compared with which the worst prison now to be found in the island is a palace.[5] His fortitude is the more extraordinary because his domestic feelings were unusually strong. Indeed, he was considered by his stern brethren as somewhat too fond and indulgent a parent. He had four small children, and among them a daughter who was blind, and whom he loved with peculiar tenderness. He could not, he said, bear even to let the wind blow on her; and now she must suffer cold and hunger; she must beg; she must be beaten; "yet," he added, "I must, I must do it."

His second wife, whom he had married just before his arrest, tried in vain for his release; she even petitioned the House of Lords on his behalf. While he lay in prison he could do nothing in the way of his old trade for the support of his family. He determined, therefore, to take up a new trade. He learned to make long-tagged thread laces; and many thousands of these articles were furnished by him to the hawkers. While his hands were thus busied he had other employments for his mind and his lips. He gave religious instruction to his fellow-captives, and formed from among them a little flock, of which he was himself the pastor. He studied indefatigably the few books which he possessed. His two chief companions were the Bible and Fox's Book of Martyrs. His knowledge of the Bible was such that he might have been called a living concordance; and on the margin of his copy of the Book of Martyrs are still legible the ill-spelt lines of doggerel in which he expressed his reverence for the brave sufferers, and his implacable enmity to the mystical Babylon.

Prison life gave him leisure to write, and during his first imprisonment he wrote, in addition to several tracts and some verse, Grace Abounding to the Chief of Sinners, the narrative of his own religious experience. The book was published in 1666. A short period of freedom was followed by a second offence and a further imprisonment. Bunyan's works were coarse, indeed, but they showed a keen mother wit, a great command of the homely mother tongue, an intimate knowledge of the English Bible, and a vast and dearly bought spiritual experience. They therefore, when the corrector of the press had improved the syntax and the spelling, were well received.

Much of Bunyan's time was spent in controversy. He wrote sharply against the Quakers, whom he seems always to have held in utter abhorrence. He wrote against the liturgy of the Church of England. No two things, according to him, had less affinity than the form of prayer and the spirit of prayer. Those, he said with much point, who have most of the spirit of prayer are all to be found in gaol; and those who have most zeal for the form of prayer are all to be found at the alehouse. The doctrinal Articles, on the other hand, he warmly praised and defended. The most acrimonious of all his works is his Defence of Justification by Faith, an answer to what Bunyan calls "the brutish and beastly latitudinarianism" of Edward Fowler, afterwards bishop of Gloucester, an excellent man, but not free from the taint of Pelagianism.

Bunyan had also a dispute with some of the chiefs of the sect to which he belonged. He doubtless held with perfect sincerity the distinguishing tenet of that sect, but he did not consider that tenet as one of high importance, and willingly joined in communion with pious Presbyterians and Independents. The sterner Baptists, therefore, loudly pronounced him a false brother. A controversy arose which long survived the original combatants. The cause which Bunyan had defended with rude logic and rhetoric against Kiffin and Danvers has since been pleaded by Robert Hall with an ingenuity and eloquence such as no polemical writer has ever surpassed.

During the years which immediately followed the Restoration, Bunyan's confinement seems to have been strict. But as the passions of 1660 cooled, as the hatred with which the Puritans had been regarded while their reign was recent gave place to pity, he was less and less harshly treated. The distress of his family, and his own patience, courage and piety, softened the hearts of his judges. Like his own Christian in the cage, he found protectors even among the crowd at Vanity Fair. The bishop of the diocese, Dr Barlow, is said to have interceded for him. At length the prisoner was suffered to pass most of his time beyond the walls of the gaol, on condition, as it should seem, that he remained within the town of Bedford.

He owed his complete liberation to one of the worst acts of one of the worst governments that England has ever seen. In 1671 the Cabal was in power. Charles II. had concluded the treaty by which he bound himself to set up the Roman Catholic religion in England. The first step which he took towards that end was to annul, by an unconstitutional exercise of his prerogative, all the penal statutes against the Roman Catholics; and in order to disguise his real design, he annulled at the same time the penal statutes against Protestant nonconformists. Bunyan was consequently set at large.[6] In the first warmth of his gratitude he published a tract, in which he compared Charles to that humane and generous Persian king, who, though not himself blest with the light of the true religion, favoured the chosen people, and permitted them, after years of captivity, to rebuild their beloved temple.

Before he left his prison he had begun the book which has made his name immortal.[7] The history of that book is remarkable. The author was, as he tells us, writing a treatise, in which he had occasion to speak of the stages of the Christian progress. He compared that progress, as many others had compared it, to a pilgrimage. Soon his quick wit discovered innumerable points of similarity which had escaped his predecessors. Images came crowding on his mind faster than he could put them into words, quagmires and pits, steep hills, dark and horrible glens, soft vales, sunny pastures, a gloomy castle, of which the courtyard was strewn with the skulls and bones of murdered prisoners, a town all bustle and splendour, like London on the Lord Mayor's Day, and the narrow path, straight as a rule could make it, running on up hill and down hill, through city and through wilderness, to the Black River and the Shining Gate. He had found out, as most people would have said, by accident, as he would doubtless have said, by the guidance of Providence, where his powers lay. He had no suspicion, indeed, that he was producing a masterpiece. He could not guess what place his allegory would occupy in English literature; for of English literature he knew nothing.