Sahih al-Bukhari, Book 68, Hadith 35 (In-Book)

Narrated Ibn 'Abbas: The pagans were of two kinds as regards their relationship to the Prophet and the Believers. Some of them were those with whom the Prophet was at war and used to fight against, and they used to fight him; the others were those with whom the Prophet made a treaty, and neither did the Prophet fight them, nor did they fight him. If a lady from the first group of pagans emigrated towards the Muslims, her hand would not be asked in marriage unless she got the menses and then became clean. When she became clean, it would be lawful for her to get married, and if her husband emigrated too before she got married, then she would be returned to him. If any slave or female slave emigrated from them to the Muslims, then they would be considered free persons (not slaves) and they would have the same rights as given to other emigrants. The narrator then mentioned about the pagans involved with the Muslims in a treaty, the same as occurs in Mujahid's narration. If a male slave or a female slave emigrated from such pagans as had made a treaty with the Muslims, they would not be returned, but their prices would be paid (to the pagans).

حَدَّثَنَا إِبْرَاهِيمُ بْنُ مُوسَى، أَخْبَرَنَا هِشَامٌ، عَنِ ابْنِ جُرَيْجٍ، وَقَالَ، عَطَاءٌ عَنِ ابْنِ عَبَّاسٍ، كَانَ الْمُشْرِكُونَ عَلَى مَنْزِلَتَيْنِ مِنَ النَّبِيِّ صلى الله عليه وسلم وَالْمُؤْمِنِينَ، كَانُوا مُشْرِكِي أَهْلِ حَرْبٍ يُقَاتِلُهُمْ وَيُقَاتِلُونَهُ، وَمُشْرِكِي أَهْلِ عَهْدٍ لاَ يُقَاتِلُهُمْ وَلاَ يُقَاتِلُونَهُ، وَكَانَ إِذَا هَاجَرَتِ امْرَأَةٌ مِنْ أَهْلِ الْحَرْبِ لَمْ تُخْطَبْ حَتَّى تَحِيضَ وَتَطْهُرَ، فَإِذَا طَهُرَتْ حَلَّ لَهَا النِّكَاحُ، فَإِنْ هَاجَرَ زَوْجُهَا قَبْلَ أَنْ تَنْكِحَ رُدَّتْ إِلَيْهِ، وَإِنْ هَاجَرَ عَبْدٌ مِنْهُمْ أَوْ أَمَةٌ فَهُمَا حُرَّانِ وَلَهُمَا مَا لِلْمُهَاجِرِينَ‏.‏ ثُمَّ ذَكَرَ مِنْ أَهْلِ الْعَهْدِ مِثْلَ حَدِيثِ مُجَاهِدٍ وَإِنْ هَاجَرَ عَبْدٌ أَوْ أَمَةٌ لِلْمُشْرِكِينَ أَهْلِ الْعَهْدِ لَمْ يُرَدُّوا، وَرُدَّتْ أَثْمَانُهُمْ‏.‏

sunnah.com