1570s, from gasp (v.). Earliest attested use is in the phrase last gasp "final breath before dying." To gasp up the ghost "die" is attested from 1530s.
gasp (v.)
late 14c., gaspen, "open the mouth wide; exhale," of uncertain origin, perhaps from Old Norse geispa "to yawn," or its Danish cognate gispe "gasp," which probably are related to Old Norse gapa "open the mouth wide" (see gap (n.)). Related: Gasped; gasping.