From the perspective of ancient Near Eastern legal history including standard legal frameworks like the Code of Hammurabi and Nuzi tablets, children born to a legal surrogate or handmaid (such as Hagar) were considered completely legitimate heirs of the father if the primary marriage was barren.
The biblical narrative confirms this legal status by recording that God blessed Ishmael, promised to make him a great nation precisely because he was Abraham's physical seed, and explicitly commanded Abraham to circumcise him as a full member of the sacred covenant.