As the Midianite merchants were passing through, they extracted Joseph from the cistern and sold Joseph for 20 pieces of silver to the Ishmaelites, who then took Joseph down to Egypt.