Genesis 39:19-20
19 And it came to pass, when his master heard the words of his wife, which she spake unto him, saying, After this manner did thy servant to me; that his wrath was kindled. 20 And Joseph's master took him, and put him into the prison, a place where the king's prisoners were bound: and he was there in the prison. 21 But the LORD was with Joseph, and showed him mercy, and gave him favour in the sight of the keeper of the prison. 22 And the keeper of the prison committed to Joseph's hand all the prisoners that were in the prison; and whatsoever they did there, he was the doer of it. 23 The keeper of the prison looked not to any thing that was under his hand; because the LORD was with him, and that which he did, the LORD made it to prosper.
Here is, 1. Joseph wronged by his master. He believed the accusation, and either Joseph durst not make his defence by telling the truth, as it would reflect too much upon his mistress, or his master would not hear it, or would not believe it, and there is no remedy, he is condemned to perpetual imprisonment, v. 19, 20. God restrained his wrath, else he had put him to death; and that wrath which imprisoned him God made to turn to his praise, in order to which Providence so disposed that he should be shut up among the king's prisoners, the state-prisoners. Potiphar, it is likely, chose that prison because it was the worst; for there the iron entered into the soul (Ps. cv. 18), but God designed to pave the way to his enlargement. He was committed to the king's prison, that he might thence be preferred to the king's person. Note, Many an action of false imprisonment will, in the great day, be found to lie against the enemies and persecutors of God's people. Our Lord Jesus, like Joseph here, was bound, and numbered with the transgressors. 2. Joseph owned and righted by his God, who is, and will be, the just and powerful patron of oppressed innocence. Joseph was at a distance from all his friends and relations, had not them with him to comfort him, or to minister to him, or to mediate for him; but the Lord was with Joseph, and showed him mercy, v. 21. Note, (1.) God despises not his prisoners, Ps. lxix. 33. No gates nor bars can shut out his gracious presence from his people; for he has promised that he will never leave them. (2.) Those that have a good conscience in a prison have a good God there. Integrity and uprightness qualify us for the divine favour, wherever we are. Joseph is not long a prisoner before he becomes a little ruler even in the prison, which is to be attributed, under God, [1.] To the keeper's favour. God gave him favour in the sight of the keeper of the prison. Note, God can raise up friends for his people even where they little expect to find them, and can make them to be pitied even of those that carry them captive, Ps. cvi. 46. [2.] To Joseph's fitness for business. The keeper saw that God was with him, and that every thing prospered under his hand; and therefore entrusted him with the management of the affairs of the prison, v. 22, 23. Note, Wisdom and virtue will shine in the narrowest spheres. A good man will do good wherever he is, and will be a blessing even in bonds and banishment; for the Spirit of the Lord is not bound nor banished, witness St. Paul, Phil. i. 12, 13.