The two men, thought to be in their late 20s, got into difficulties as they sailed around the island of Ailsa Craig off the Ayrshire coast on Tuesday afternoon.
Their Wayfarer dinghy capsized in moderate seas and the locker compartment flooded, leaving them unable to right the boat.
One of the men used his mobile phone to call a friend who is a member of the Campbeltown RNLI crew, who in turn alerted Belfast's Coastguard station. Mine-hunter HMS Blyth, which was about three miles away, responded to the coastguard's call for assistance at about 3pm. When it arrived at the scene it launched its sea boat to recover the two men, who were cold but otherwise uninjured.
Lieutenant Commander Mark Redmayne, commanding officer of HMS Blyth, said: "As soon as we got the call from the coastguard at about 3pm, we responded by deploying my ship's company as lookouts. Soon after, one of our diving team spotted the lads on the upturned dinghy. It was very fortuitous that we were passing at the right place, at the right time, considering we are on our way to the Mediterranean.
"They were recovered by our sea boat and looked like a pair of drowned rats. They had been clinging to the boat in the water for about 60 minutes but once aboard HMS Blyth we were able to offer them a shower and some overalls to wear."
The two men had set out from Largs on Tuesday for a two-day sailing trip and planned to sail around Ailsa Craig in the 16ft dinghy before staying the night at Lamlash on Arran.
The Girvan lifeboat Sylvia Burrell took the two men back to the mainland.
The warship was travelling from her base port at Faslane for a three-month Nato deployment to the Mediterranean.
Ailsa Craig is renowned for its seabird population, supporting 73,000 breeding seabirds.