Deuteronomy

Deuteronomy 21:16

16when that man assigns his inheritance to his sons he must not appoint [the son] of the beloved wife as the firstborn over the son of the unloved wife.