Leviticus 25:44-54

25:44 “‘As for your male and female slaves who may belong to you – you may buy male and female slaves from the nations all around you. 25:45 Also you may buy slaves from the children of the foreigners who reside with you, and from their families that are with you, whom they have fathered in your land, they may become your property. 25:46 You may give them as inheritance to your children after you to possess as property. You may enslave them perpetually. However, as for your brothers the Israelites, no man may rule over his brother harshly.

25:47 “‘If a resident foreigner who is with you prospers and your brother becomes impoverished with regard to him so that he sells himself to a resident foreigner who is with you or to a member of a foreigner’s family, 25:48 after he has sold himself he retains a right of redemption. One of his brothers may redeem him, 25:49 or his uncle or his cousin may redeem him, or anyone of the rest of his blood relatives – his family – may redeem him, or if he prospers he may redeem himself. 25:50 He must calculate with the one who bought him the number of years from the year he sold himself to him until the jubilee year, and the cost of his sale must correspond to the number of years, according to the rate of wages a hired worker would have earned while with him. 25:51 If there are still many years, in keeping with them he must refund most of the cost of his purchase for his redemption, 25:52 but if only a few years remain until the jubilee, he must calculate for himself in keeping with the remaining years and refund it for his redemption. 25:53 He must be with the one who bought him like a yearly hired worker. The one who bought him must not rule over him harshly in your sight. 25:54 If, however, he is not redeemed in these ways, he must go free in the jubilee year, he and his children with him,