The Royal Navy's longest-serving submarine has been decommissioned in a ceremony at a naval base Plymouth.
Nuclear-powered HMS Superb came into service in 1976 as one of six Swiftsure class hunter-killer vessels.
During the ceremony, the ship's company lined up on the quayside at Devonport while a Royal Marines band played and a ceremonial guard was held.
The vessel was taken to Devonport instead of her Faslane base after hitting rocks in the Red Sea in May.
The Ministry of Defence (MoD) said the submarine had been decommissioned only a matter of days earlier than had originally been planned following the incident.
The submarine went directly to Devonport in order have the damage assessed, but it would have gone there anyway after decommissioning to be laid up, the MoD said.
'Treasure and pleasure'
"It made abundant sense to afford her the dignity of a decommissioning ceremony at Devonport rather than have her make unnecessary voyages to and fro between Devonport and Faslane in Scotland," an MoD spokesman said.
Families, friends and other guests of the ship's company gathered to witness a 30m (98ft) long decommissioning pennant lowered on to the submarine.
The vessel's commanding officer Lt Cdr John Aitken said he was "very proud" of the company of 116.
He said: "It has been a privilege to serve with you, and I am immensely proud of every one of you. It has been an honour to have you as shipmates.
"HMS Superb has been a treasure and a pleasure to serve in."
The submarine was brought into service to counter the threat from Soviet submarines in the Atlantic during the Cold War.
It was charged with helping to protect shipping and supporting Nato operations in Europe in the event of the Cold War escalating.
A piper also took part in the ceremony
After the Cold War ended, the submarine was used by Flag Officer Sea Training staff in UK waters before travelling east of Suez to conduct operations.
While in the Red Sea in May, the vessel grounded. No-one was injured and the hull was unaffected, but it suffered some damage to its bow. It was also left unable to dive for a time because of damage to her sonar equipment.
She was eventually brought back to Devonport.
The Navy said its decommissioning had been planned to take place in the first week of October, but was brought forward because she was already at the base where the work would be carried out.
The Navy said: "HMS Superb went directly to Devonport on her return to UK so that her damage could be thoroughly assessed.
"As she would, after decommissioning, go to Devonport to be de-stored and laid up anyway, it made abundant sense to afford her the dignity of a decommissioning ceremony at Devonport rather than have her make unnecessary voyages to and fro between Devonport and Faslane in Scotland."
HMS Superb will be laid up in Devonport and kept in a safe environment for disposal at a later date, the Navy said.