The next engagement with the Dutch fleet took place on 4 August 1666, at the St. James's Day Battle. Allin was in command of the van squadron, and led the attack, engaging the Dutch van throughout the day, and chasing them from the battle scene the following day, greatly contributing to the English victory. Allin was then placed in command of a squadron off Dungeness, and on 17 September after a battle with an allied French and Dutch fleet he captured the French ship "Rubis", which was taken into service as . Allin's next command was to take over the Mediterranean forces in 1668, after the end of the Second Anglo-Dutch War, and to operate against the Barbary corsairs. A treaty was duly signed with the Algerians, but by 1669 Allin was employed again in chastising the pirates for breaches of the treaty, during which time he captured and destroyed a large number of pirate vessels. He returned to England after this and on 15 April 1671 he became Comptroller of the Navy, a post he held throughout the Third Anglo-Dutch War and continued to hold until 28 January 1680. On 7 February 1673 Allin was created a baronet for his services. He briefly returned to active service in 1678 when the threat of war with France emerged, and Allin became commander in chief of the fleet in the Narrow Seas, with as his flagship. He resigned the command once the threat of war had passed.