The word that came to Jeremiah from the Lord after Nebuzaradan the captain of the guard had let him go from Ramah, when he took him bound in fetters along with all the captives of Jerusalem and Judah who were being exiled to Babylon.
The captain of the guard took Jeremiah and said to him, "The Lord your God threatened this place with this disaster;
and now the Lord has brought it about, and has done as he said, because all of you sinned against the Lord and did not obey his voice. Therefore this thing has come upon you.
Now look, I have just released you today from the fetters on your hands. If you wish to come with me to Babylon, come, and I will take good care of you; but if you do not wish to come with me to Babylon, you need not come. See, the whole land is before you; go wherever you think it good and right to go.
If you remain, then return to Gedaliah son of Ahikam son of Shaphan, whom the king of Babylon appointed governor of the towns of Judah, and stay with him among the people; or go wherever you think it right to go." So the captain of the guard gave him an allowance of food and a present, and let him go.
References for Jeremiah 40:5
Then Jeremiah went to Gedaliah son of Ahikam at Mizpah, and stayed with him among the people who were left in the land.
When all the leaders of the forces in the open country and their troops heard that the king of Babylon had appointed Gedaliah son of Ahikam governor in the land, and had committed to him men, women, and children, those of the poorest of the land who had not been taken into exile to Babylon,
they went to Gedaliah at Mizpah—Ishmael son of Nethaniah, Johanan son of Kareah, Seraiah son of Tanhumeth, the sons of Ephai the Netophathite, Jezaniah son of the Maacathite, they and their troops.
Gedaliah son of Ahikam son of Shaphan swore to them and their troops, saying, "Do not be afraid to serve the Chaldeans. Stay in the land and serve the king of Babylon, and it shall go well with you.
As for me, I am staying at Mizpah to represent you before the Chaldeans who come to us; but as for you, gather wine and summer fruits and oil, and store them in your vessels, and live in the towns that you have taken over."
Likewise, when all the Judeans who were in Moab and among the Ammonites and in Edom and in other lands heard that the king of Babylon had left a remnant in Judah and had appointed Gedaliah son of Ahikam son of Shaphan as governor over them,
then all the Judeans returned from all the places to which they had been scattered and came to the land of Judah, to Gedaliah at Mizpah; and they gathered wine and summer fruits in great abundance.
Now Johanan son of Kareah and all the leaders of the forces in the open country came to Gedaliah at Mizpah
and said to him, "Are you at all aware that Baalis king of the Ammonites has sent Ishmael son of Nethaniah to take your life?" But Gedaliah son of Ahikam would not believe them.
Then Johanan son of Kareah spoke secretly to Gedaliah at Mizpah, "Please let me go and kill Ishmael son of Nethaniah, and no one else will know. Why should he take your life, so that all the Judeans who are gathered around you would be scattered, and the remnant of Judah would perish?"
But Gedaliah son of Ahikam said to Johanan son of Kareah, "Do not do such a thing, for you are telling a lie about Ishmael."