Origin

Late Middle English: past participle of the obsolete verb agast, gast 'frighten', from Old Englishgǣsten. The spelling with gh (originally Scots) became general by about 1700, probably influenced by ghost; compare with ghastly.

Gast (originally gaestan) was an Old English word meaning ‘frighten or terrify’. It was still being used in this sense in Shakespeare's day: ‘Or whether gasted by the noise I made, Full suddenly he fled’ (King Lear). This gave rise to agast, which had the same meaning. The spelling aghast (probably influenced by the spelling of ghost) was originally Scottish but became generally used after 1700. Ghastly (Middle English) comes from the same word. The sense ‘objectionable’ dates from the mid 19th century.