A senior Royal Navy officer has been blamed for his role in putting a £2.1m dent in a nuclear submarine, a court martial has heard.

Commander Justin Codd had 22 years of experience in the navy and was training students on how to navigate the £1.1bn nuclear submarine HMS Ambush.

He was instructing two candidates in the Navy's demanding Perisher programme as they manoeuvred the vessel into Gibraltar harbour on 20 July 2016 when it hit a merchant ship. The submarine was put out of action for two months while the prang was repaired.

The court martial in Portsmouth heard that Codd had not used the second periscope, relying instead on the candidates who did not tell him about the danger.

Captain John Atwill, for the prosecution, said Codd had made the mistake of thinking that MV Andreas was not a threat because it could not be seen and after it had avoided a yacht, it should have dived to avoid a collision.

"While it may be justifiable to take risks in war situations it is not justifiable in a training exercise. His decision to focus on teaching and not safety compounded the errors made by the students.

"He believed his understanding was enough to keep the submarine safe, the very fact of the collision disproves this."

Captain Sean Moore, representing Codd, said: "Because of a few minutes of distraction, all he had worked so hard for over 20 years was put in jeopardy. No one becomes a teacher because they are good enough, they must be the best.

"He allowed himself for only a few minutes to lose focus of his primary goal and that's safety." He added: "At the very end of a very long period of training, with the finish line in sight, he took his eye off the ball," the Times reported.

He admitted one charge of hazarding a ship and as punishment forfeited one year of seniority.