Sayyiduna Jabir (may Allah be pleased with him) said: A slave came and pledged allegiance to the Prophet (peace and blessings be upon him) on emigration (hijrah). He (peace and blessings be upon him) did not know that he was a slave. His master came wanting him (back), so the Prophet (peace and blessings be upon him) said: "Sell him to me." He (peace and blessings be upon him) bought him for two black slaves. After that he (peace and blessings be upon him) did not take allegiance from anyone until he had asked whether he was a slave.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب البيوع / 10522