I was wondering how this term for yes came to be used in the navy and how long that had been so. Surprisingly it’s of unknown origin according to OED, appeared suddenly about 1575 and was exceedingly common by about 1600. Here’s the rest of the etymology from OED and the earliest cite.
The suggestion that it is the same as ay adv. ‘ever, always,’ seems set aside by the fact that it was at first always written I , a spelling never found with ay adv. But it may have been a dialect form of that word, from some dialect in which it had passed through the senses of always , in all cases , to by all means , certainly , yes (compare aye but , in sense A. 2b; and the history of algate adv.), and so have been taken in literary English for a different word. It is less easy to see in it a phonetic variant or dialect form of ya ‘yea, yes.’ Spelt both aye and ay : the former is in accordance with parliamentary usage, and better on every ground. Aye and eye (which many identify in pronunciation, and which differ at most only in the ‘broader’ or more back sound of aye ), are analogous diphthongal words usefully distinguished by their final e from the regular pronunciation of -ay , -ey , in bay , day , gay , hay , etc., and bey , dey , grey , they , convey , etc.: see ay adv.
1576 G. Wapull Tyde taryeth no Man sig. B.i If you say I syr, we will not say no.
No mention of the Scottish aye but surely they’re related? In the UK the word is used mainly in Parliament and the Royal Navy. I know the US navy also uses the word, is it also used in Congress?