Jeremiah [started to] leave Jerusalem to go to the land of Benjamin to claim his portion there among the people.
References for Jeremiah 37:12
But when he was at the Benjamin Gate, an officer of the guard was there, whose name was Irijah son of Shelemiah, son of Hananiah, and he apprehended Jeremiah the prophet, saying, "You are deserting to the Chaldeans."
"[That's] a lie," Jeremiah replied. "I am not deserting to the Chaldeans!" Irijah would not listen to him but apprehended Jeremiah and took him to the officials.
The officials were angry at Jeremiah and beat him and placed him in jail in the house of Jonathan the scribe, for it had been made into a prison.
References for Jeremiah 37:15
So Jeremiah went into a cell in the dungeon and stayed there many days.
References for Jeremiah 37:16
King Zedekiah later sent [for him] and received him, and in his house privately asked him, "Is there a word from the Lord?" "There is," Jeremiah responded, and he continued, "You will be handed over to the king of Babylon."
References for Jeremiah 37:17
Then Jeremiah said to King Zedekiah, "How have I sinned against you or your servants or these people that you have put me in prison?
Where are your prophets who prophesied to you, claiming, 'The king of Babylon will not come against you and this land'?
References for Jeremiah 37:19
So now please listen, my lord the king. May my petition come before you. Don't send me back to the house of Jonathan the scribe, or I will die there."
So King Zedekiah gave orders, and Jeremiah was placed in the guard's courtyard. He was given a loaf of bread each day from the baker's street until all the bread was gone from the city. So Jeremiah remained in the guard's courtyard.
References for Jeremiah 37:21