D-2 was launched as Grayling (SS-18) 16 June 1909 by Fore River Shipbuilding Co., Quincy, Mass., under subcontract from Electric Boat Co., Groton, Conn.; sponsored by Miss. C. H. Bowles; and commissioned 23 November 1909, Lieutenant Owen Hill in command. She was renamed D-2 on 17 November 1911.
D-2 joined the Atlantic Torpedo Fleet as Flagboat for Submarine Division 3. Along the Atlantic coast, D-2 joined in diving, torpedo, and experimental exercises. She participated in the Presidential Review of the Fleet in North River, N.Y. from 5 to 18 May 1915.
During World War I D-2 served in training and experimental work at New London. She was placed in commission in reserve at Philadelphia Navy Yard 9 September 1919 and placed in ordinary 15 July 1921. Towed to Philadelphia Navy Yard, she was decommissioned 18 January 1922 and sold as a hulk 25 September 1922.