Question: Who sold Joseph into slavery? Genesis 37:36 says the Midianites sold Joseph in Egypt to Potiphar, the courtier of Pharaoh. But Genesis 39:1 says the Ishmaelites brought Joseph to Egypt and sold him to Potiphar, the courtier of Pharaoh.
Response: Both are true. Genesis 37:36 (NIV) says that the Midianites sold Joseph to Potiphar. And Genesis 39:1 (NIV) says that the Ishmaelites sold Joseph to Potiphar. And that might seem like a contradiction, but Genesis 37:28 (NIV), shows that both the Ishmaelites and the Midianites were involved in the selling of Joseph:
"So when the Midianite merchants came by, his brothers pulled Joseph up out of the cistern and sold him for twenty shekels of silver to the Ishmaelites, who took him to Egypt." - Genesis 37:28 (NIV).
In this verse, both tribes are mentioned in connection with the sale of Joseph.
In reading Genesis 37:36 and the first part of Genesis 37:28, perhaps the Midianites were the ones who arranged the buying and selling of Joseph. The Midianites are described as merchants in Genesis 37:28. And, in reading Genesis 39:1 and the second part of Genesis 37:28, it seems clear that the Ishmaelites physically carried out the transport and sale of Joseph. Both tribes were responsible and accountable for the sale of Joseph.
Incidentally, the Midianites and the Ishmaelites were related. The Ishmaelites were descendents of Abraham through Hagar. And the Midianites were descendants of Abraham through Keturah.
I have seen commentary from Christian researchers that claim that the terms "Midianites" and "Ishmaelites" were interchangeable. This is partly based on the use of the two tribal names in Judges 8:22 and Judges 8:24, which indicate that the names might have been interchangeable. Perhaps the names were interchangeable because the two tribes were intermixed to the extent that either name would suffice in describing them.
In any event, Genesis 37:28 mentions both tribal names in connection with the sale of Joseph. And that alone undermines any claim of contradiction.