The Ministry of Defence (MoD) said the trial is part of Nato's Exercise Formidable Shield, which is currently taking place off the coast of Scotland until June 3.
The research is being led by Defence Science and Technology Laboratory (DSTL) scientists - with the AI being tested on destroyer HMS Dragon and frigate HMS Lancaster.
The MoD said the AI improves the early detection of lethal threat, accelerates engagement timelines and provides Royal Navy Commanders with a rapid hazard assessment to select the optimum weapon or measure to counter and destroy the target.
The trial is testing two AI applications, Startle and Sycoiea, with the former designed to provide live recommendations and alerts to sailors monitoring the "Air Picture", and the latter identifying the nearest threat and how best to deal with it.
M6 reopens after vehicle transporting sheep overturns following crash between Preston and Lancaster
Lytham St Annes care home boss appears in court after death of residents
The Old Vicarage Care Home: special measures status for Lancashire care home where resident was left lying on floor after falling out of bed
Morecambe 'neighbour from hell' back in court after breaching order
Preston Brick Veil Mosque inquiry closes as debate rages over whether the place of worship should be permitted
Scottish Secretary Alister Jack said: "It's vital that our brave and highly skilled armed forces stay ahead of the game for the security of the United Kingdom and our allies.
"The Royal Navy's use of AI for the first time at sea is an important development in ensuring readiness to tackle threats we may face.
"I'm proud to see that two Scottish-built Royal Navy vessels are at the heart of this exercise in the waters off the Hebrides."
The AI-based applications are also being tested to ensure they work alongside existing radar and combat management systems.
DSTL's programme manager Alasdair Gilchrist said: "DSTL has invested heavily in the systems that are installed at the moment, but it's imperative that we continue to invest to make sure that the Royal Navy remains relevant now and in the future.
"Being able to bring AI onto the ships is a massive achievement, and while we can prove the AI works in the labs, actually getting Navy personnel hands on is brilliant."
HMS Lancaster's Weapon Engineer Officer, Lieutenant Commander Adam Leveridge said: "Observing Startle and Sycoiea augment the human warfighter in real time against a live supersonic missile threat was truly impressive - a glimpse into our highly-autonomous future."