Old Ironsides is taking one last spin in Boston Harbor before it heads to dry dock for a three-year restoration project.

The USS Constitution, the world's oldest commissioned warship still afloat, is set to depart from its berth at the Charlestown Navy Yard with about 500 specially-invited guests Friday morning.

The ship will give a 21-gun salute off Fort Independence on Castle Island, one of the oldest fortified sites in the country, as well as a 17-gun salute at the Coast Guard's Boston base.

After Friday's trip, the ship will undergo dry-dock preparations, including removal of its upper masts and offloading of the ship's long guns. The three-mast frigate still will be open for public tours Thursday through Sunday, starting Oct. 20. It officially enters dry dock in March 2015.

During the restoration, workers are expected to re-copper the ship's hull, replace worn riggings, change out old planks on the gun and berth decks and make general repairs to the stern, bow and captain's cabin. The ship is expected to be back in the water by 2017. By spring or summer 2018 it should return to its familiar spot on Pier 1 at the Navy Yard.

Built in Boston and launched in October 1797, the USS Constitution was commissioned by the U.S. Navy following the Revolutionary War in order to protect American merchant ships off the northern coast of Africa.

It earned the nickname "Old Ironsides" after winning numerous battles during the War of 1812 against Great Britain. Over the years, the iconic ship has held a variety of roles in the Navy. Today with an all active-duty Navy crew, it is a major tourist destination in Boston, with more than 500,000 visitors a year.