Ishmaelite merchants took Joseph with them into Egypt. The king of that country was named Pharaoh, and one of the chief officers in his army was named Potiphar. Potiphar bought Joseph from the merchants to be his slave. And he found him to be so good and trustworthy that he gave him charge of the whole house, and taught him the learning that became a free man, and gave him leave to eat at his own table instead of the table of the other servants.

But after a while the wife of Potiphar persuaded her husband that Joseph was a wicked man, and Potiphar was angry and threw him into prison.

Even in the prison, however, God raised up friends for Joseph. The keeper of the prison, himself, was moved kindly to him, because he found that Joseph was careful and faithful in everything that he asked him to do, and he therefore set him over the other prisoners, as Potiphar had set him over the other servants, and allowed him also better food than was given to the rest. Nor were the other prisoners jealous of him, for they also learned to like him and respect him. Often after the hard labors of the day were over they gathered together to discourse among themselves, and to inquire one of the other what was the reason of their being condemned to a prison. Among these prisoners were two of the king's servants who had offended him; one was his cup-bearer, who carried his wine-cup to him when he wanted to drink, and the other was his chief baker. And these men were under the care of Joseph, and were friendly to him.

One day the cup-bearer told Joseph of a dream he had had, and asked him to interpret it. He saw in his sleep a vine with three branches, and on each branch was a cluster of grapes, large already and ripe for gathering. And he squeezed the juice of these grapes into a cup and gave this cup to the king to drink, and the king received it from him with a pleasant countenance. Then Joseph told him to be of good cheer, for that the three branches he had seen in his dream meant three days, and within three days Pharaoh would send for him to be taken out of prison, and he should wait on the king and give the cup into his hand as he had been accustomed to do. Then Joseph told him he should remember his friends when this good fortune arrived, and should speak to the king concerning himself, who had been unjustly put into prison.

Now when the chief baker had heard Joseph's interpretation of the cup-bearer's dream he was glad. For he, too, had dreamed a dream, and he hoped that it had an equally pleasant meaning. So he told it to Joseph.

"I thought," he said, "that I was carrying three baskets on my head, one on top of the other. Two were full of loaves, and the third contained sweetmeats and other eatables such as are prepared fro kings. But the birds of the air came flying and ate them all up, though I tried to drive them away."

When Joseph heard this dream he felt grieved for his friend. And he told him that the baskets meant three days, and that on the third day he should be crucified and devoured by fowls, while he was not able to help himself.

It came to pass exactly as Joseph had foretold. On the third day after this conversation was the king's birthday, when he made a feast to all his servants. And he sent to the prison and freed the cup-bearer from his bonds and restored him to his former position. But he had the chief baker taken out and crucified.

For two years longer Joseph remained in prison, as the cup-bearer forgot all about him in his good fortune, and did not speak to the king as he had promised. But at the end of that time the cup-bearer was reminded of his friend in the following manner. Pharaoh one night dreamed two dreams which troubled him exceedingly, for they seemed to predict evil. And he called together all the wise men of the country, but when they could give him no interpretation of his dreams he was still more troubled. And now it was that the memory of Joseph and his skill in dreams came into the mind of the cup-bearer. So he went to the king and told him how when he and the chief baker were in prison together they each of them had a dream, and the dream was interpreted to them by a young man who was their companion in prison, and what the young man told them came true.

Then the king commanded that Joseph should be taken out of prison and brought to him. When the young man appeared, Pharaoh told him that he had heard of his skill in interpreting dreams, and that he had dreamed two dreams whose meaning he wished to know. And then he told him his dreams.

"I thought," said the king, "that as I stood by the river seven cows cam up out of the water. They were large and fat, and they went into the marshes near by. And seven other cows, who were lean and ill-favored, came up to meet them out of the marshes, and they ate up the fat cows, yet they remained as lean and ill-favored as before. And then I awoke. And I fell asleep again, and saw another dream, much more wonderful that the other, which disturbed me still more. I saw seven ears of corn growing up out of one root. They were all good and filled with grain. And near these I saw seven other ears of corn, and they were spoiled and bad and had no good grain in them. And the seven bad ears ate up the seven good ones."

Then Joseph told the king that both his dreams signified one and the same thing. The seven fat cows and the seven good ears meant seven years of plenty and fruitfulness, while the seven lean cows and the seven bad ears meant seven years of famine and distress. And the meaning of the dreams was that there would come seven good years in Egypt, when the wheat would grow well and there would be plenty for the people to eat. But after those seven good years would come seven years of famine, when the grain would not grow well and the people would want for bread.

Then Joseph advised Pharaoh what he should do in order to provide against this famine. He told him that during the seven good years he should see that the Egyptians were not wasteful of the grain, but were made to reserve what they would have spent in luxury and beyond their necessity for the time of want. And the best way to do this, he said, would be to take the grain away from the husbandmen as soon as it was ripe, and allow them only so much as would be sufficient for their wants. The king consented to do as he was told, and he said that as Joseph had shown so much wisdom in explaining his dreams and in advising him what to do, he would intrust him with the duty of saving up the grain, and give him power to do what he thought would be for the benefit of the people of Egypt and of the king.

So instead of being sent back to prison Joseph was made on of the great men in the court of Pharaoh. And he was clothed with purple, which only the greatest men were allowed to wear, and he drove in his chariot through all the land of Egypt, and took the grain from the husbandmen, allowing them only so much as was necessary fro food and for seed. But he did not tell any of them the reason why he did so. The grain he took in this manner he put away in storehouses, that it might be kept safe until the seven years of famine began.