Even under arrest, Jeremiah keeps preaching.
Jeremiah is under guard in the court of the guardhouse and he keeps preaching God's warning to the people: go with the Chaldeans and you will get to live; stay in Jerusalem and die.
The officials saw that his words still had influence. Soldiers left behind were losing heart for the fight and such. So the officials went to King Zedekiah and demanded that he kill Jeremiah. They claim Jeremiah did not care for the well-being of the people. Zedekiah pulls a pre-Pontius Pilot and washes his hands of the decision. He claims, weirdly, that he has no control over what they do.
They lower Jeremiah into the mud at the bottom of an empty cistern. To me, that makes even their murder lazy and cowardly. If they really thought he was bad for the people, why not do a public execution?
An Ethiopian eunuch who worked in the palace saw what happened and went to the king to warn him that Jeremiah would die in that cistern, since there was no bread left in the city. The Ryrie footnote points out that the only person who acted on Jeremiah's behalf was a foreigner- none of his own people came to his aid. The king sends the eunuch with 30 men to pull Jeremiah out. Once freed, he went back to the court of the guardhouse.
Then the king brought Jeremiah to one of the entrances to the Temple and asks him for an honest answer. To which, Jeremiah points out that the king never lostens and will just put him to death for an honest answer. Zedekiah swears not to put him to death or hand him over to the murderous officials.
So Jeremiah tells him straight:
Then Jeremiah said to Zedekiah, “Thus says the Lord God of hosts, the God of Israel, ‘If you will indeed go out to the officers of the king of Babylon, then you will live, this city will not be burned with fire, and you and your household will survive. 18 But if you will not go out to the officers of the king of Babylon, then this city will be given over to the hand of the Chaldeans; and they will burn it with fire, and you yourself will not escape from their hand.’” Jeremiah 38:17-18
Zedekiah replies that he's afraid to comply because the of the Jews that have already been sent to Babylon. He thinks they will want revenge on their king for failing them.
Jeremiah tries to quell his fears, encouraging him to obey the Lord, so that it will go well for him. However, in addition to the encouragement to do right, comes a warning if Zedekiah keeps refusing- his harem, wives, and children will be brought out and testify to how the his own officials and friends have been betraying him, then the king of Babylon will take him anyway, AND Jerusalem will burn. So the king could protect his women, children, and the whole city by simply obeying God...or...not.
Zedekiah commands that Jeremiah keep this secret and promises that if he does, he will live. He commands Jeremiah to deceive the officials if they show up and want to know about the conversation between Jeremiah and the king. the officials do show up and want to know about that conversation and Jeremiah does what the king asks.
So Jeremiah stayed in the court of the guardhouse until the day that Jerusalem was captured. Jeremiah 38:28