A senior naval officer in charge of teaching future submarine captains “took his eye off the ball”, leading his nuclear submarine to collide with a tanker, a court martial has heard.

Commander Justin Codd, 45, of UK Maritime Battle Staff, was sentenced to forfeiting a year of seniority after pleading guilty at Portsmouth Naval Base to negligently hazarding the £1.1 billion submarine HMS Ambush.

The Astute-class submarine was taken out of service for three months to undergo repairs costing £2.1 million.

Sentencing Codd, Judge Advocate Robert Hill said: “You have, save for this incident, an exemplary record. It was more in the nature of a momentary aberration than a careless attitude.”

Captain John Atwill, prosecuting, said that Codd was leading a group of students on the final day of the Perisher training course when the accident happened off Gibraltar on July 20 2016.

He explained that the students were practising controlling the submarine at periscope depth observing shipping movements.

Cpt Atwill said the failure happened because, despite the submarine having two periscopes, Codd failed to carry out his own observations and relied on the images provided by his students.

He said that the students had focused on a yacht called Katharsis and had not identified the risk posed by the tanker MV Andreas, which was “loitering” in the nearby area.

Cpt Atwill said: “Cdr Codd’s decision to focus on teaching, not safety, compounded the error carried out by the students.”

Captain Sean Moore, defending, said that the incident was the worst day in the defendant’s 22 years of “exemplary service”.

He said: “This is a failure that will live with him for the rest of his life.

“No officer becomes teacher of the Submarine Command Course because they are good enough, they must be the best the submarine service has to offer.

“Perisher is widely acknowledged as the toughest command course in the world.”

He added: “This was a case where at the end of a long and demanding period of training with the finish line in sight, Cdr Codd took his eye off the ball.”

He continued: “This is not a case of teacher deliberately ignoring an obvious threat or taking a calculated risk.”

Cpt Moore said that Codd was highly respected by senior commanders and had been involved in learning lessons from the accident.

He added that the senior students involved in the training had gone on to pass the Perisher course.

Cpt Moore said: “Not only did he remain as teacher but he revised the training procedures.

“Having written the book on optronic periscopes, having learned from this incident, he’s taken the lead in rewriting the book.”

The court heard that the punishment would impact on Codd’s career progression and his salary of £78,000 a year.