Jeremiah 32:2

For then the king of Babylon’s army besieged Jerusalem: and Jeremiah the prophet was shut up in the court of the prison, which was in the king of Judah’s house.

The setting is the third and last siege of Jerusalem by the Chaldean armies, coming in the closing years of Judah's apostasy. By then the exhortations of the prophets seemed to be of little avail, and hope had fled from every heart. Jeremiah was shut up in the court of the prison because he predicted utter ruin for the city and insisted that it surrender.

In his confinement he was kept under close surveillance by those who scorned his messages. Yet even in prison God did not leave the faithful remnant still in the city to hopeless despair, but gave Jeremiah fresh revelations of heaven's willingness to forgive and to save. Those revelations given during his imprisonment remain an unfailing source of comfort to the church of God.