The army of Pharaoh, King Hophra or Apries (590-571 BCE), had come out of Egypt to do battle with the Babylonians, probably around 588 BCE. When the Chaldean Babylonian soldiers heard this, they stopped their siege of Jerusalem. Did King Zedekiah have some sort of agreement with the Egyptian king? Did the Chaldeans fight against the Egyptians? Anyway, things looked good for Jerusalem at least for the time being.
The time frame is clearly the time of the siege of Jerusalem by the Babylonian army. However, Jeremiah was imprisoned in the palace jail by King Zedekiah of Judah. King Zedekiah had been installed as king by King Nebuchadnezzar in 598 BCE. However, he revolted against him and sought the aid of King Hophra or Pharaoh Apries (589-570 BCE) of Egypt. This led to the siege that lasted almost 2 years as the Egyptians tried to help King Zedekiah. Eventually, the Babylonians were successful. Meanwhile, King Zedekiah had Jeremiah confined to prison because, as always, Jeremiah was pro-Babylonian.