From the Celtiberian name Magal. Compare the Anglicized Magellan and Spanish Magallanes.
Magalhães m or f by sense