Following the end of the Second World War, the Imperial Japanese Navy gave up a number of ships as a part of reparations. The destroyer Hibiki, for instance, went to the USSR, and the destroyer Yukikaze was handed over to the Republic of China. The British took over a number of IJN ships moored in Singapore, most notably the heavy cruisers Takao and Myoko, though I'm uncertain as to whether or not this was as part of any signed agreement or simply a matter of convenience. The US took the battleship Nagato and the light cruiser Sakawa, along with the Kriegsmarine heavy cruiser Prinz Eugen and used them, along with a large number of USN ships, as target ships for Operation Crossroads, a nuclear test.
After WWI much of the German fleet was interned at Scapa Flow as part of the requirements for the armistice. The German naval officers and crew who manned the ships managed to scuttle a good part of the fleet in a surprise move not long after they arrived. The British were not happy.
Technically an armistice, but after the end of the first World War the entire German high seas fleet was interned by the British at Scapa Flow as part of the condition for the Nov.11 armstice. The entire fleet, which was one of the key reasons in the deterioration of Anglo-German relations because Britain feared that Germany was challenging its naval supremacy in its home waters, was scuttled by its own crew in June 1919.
When the 2nd Coalition Anglo-Russian army invaded the Dutch Batavian Republic against France in 1800, several Dutch ships who were supposed to defend the coast just sailed away and defected to the Allies when they showed up.
After waging a campaign where several battles were won but ultimately the whole thing was bungled, the Allied armies retreated and a treaty was negotiated, and the Dutch let the British keep the ships that detected as part of the terms.