The Astute-class submarine, which is the largest nuclear-powered attack craft in the Royal Navy, was submerged below the water as part of a normal training exercise when it had a "glancing collision" with a merchant ship passing by.
HMS Ambush took a hit to its outer body but the Ministry of Defence has said there was no damage to its nuclear plant and none to the other vessel.
Yet a full review of the incident will be carried out, particularly given that the Astute-class submarine is meant to have "world leading sensors" based on a special sonar system.
No one was hurt in the collision.
In a statement, the Royal Navy said: "The submarine suffered some external damage but there is absolutely no damage to her nuclear plant and no member of the ship's company was injured in the incident.
"An immediate investigation is being conducted."
The incident, which took place at 1.30pm local time on July 20, occurred off the coast of Gibraltar, a British Overseas Territory on the south-western tip of Spain.
BAE Systems, which build the Astute-class craft, announced in 2002 that the submarines would all be fitted with "the world's most advanced sonar system".
At the time, defence procurement minister Lord Bach said the new technology represented "a step change in the ability of our submarines to detect other submarines and surface ships."
HMS Ambush and two of her sister craft cost almost £4 billion when built, with construction delayed by more than four and a half years and costs exceeding the original budget by more than 50 per cent.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies