Though he had resigned from the Tangier committee in 1679, in 1683 he was sent to Tangier to assist Lord Dartmouth with the evacuation and abandonment of the English colony. After six months' service, he travelled back through Spain accompanied by the naval engineer Edmund Dummer, returning to England after a particularly rough passage on 30 March 1684. In June 1684, once more in favour, he was appointed King's Secretary for the affairs of the Admiralty, a post that he retained after the death of Charles II (February 1685) and the accession of James II. The phantom Pepys Island, alleged to be near South Georgia, was named after him in 1684, having been first "discovered" during his tenure at the Admiralty.