The Pakistan navy fought a long gun battle with militants who had attacked its Karachi dockyard, it has emerged.
The gun battle on Saturday night is said to have lasted about six hours. A Pakistani Taliban spokesman said the group carried out the attack.
A low-ranking navy personnel member and two militants were killed, while six soldiers and an officer were wounded, the navy says.
In 2011, militants carried out a major attack at a naval base in Karachi.
A navy spokesman said four militants had been captured alive after Saturday's attack. Based on information which they provided, security agencies have detained collaborators from other parts of the country.
"No material loss took place," he said. The spokesman did not give further details about the nature of the attack or possible target, or whether militants had attacked by land or sea.
Analysis: Shahzeb Jillani, BBC News, Karachi
The attack took place at a naval construction and repair facility, located in a secure area near Karachi Shipyard. Taliban militants have said they had inside help. Pakistani officials have also said that some navy personnel appeared to have collaborated with the attackers.
If true, this latest incident is a stark reminder of lingering concerns about the ability of jihadi militants to penetrate deep inside Pakistan's security installations. Of particular concern is a wave of radicalisation in the lower ranks of the Pakistan Navy, where anti-Americanism and sympathy for extremism and the Afghan jihad is said to have grown in recent years.
Questions are also being asked about how or why the news of the gun battle was withheld for more than 48 hours. Was this a rare case of the country's otherwise vibrant media working in tacit collusion with the powerful military for an alleged news blackout? Or, did the military deliberately keep the incident hidden to allow intelligence agencies to carry out raids to detain suspected collaborators?
Either way, this latest attack will no doubt be seen as a failure of the navy's security arrangements. It shows that while militants may be on the run because of the military's offensive in North Waziristan, they appear to retain the capacity to regroup and strike back at will.
BBC correspondents say news of the attack was apparently withheld from the media because of its sensitivity.
It is unclear why the Pakistan Taliban also kept silent on the matter, but on Tuesday spokesman Shahidullah Shahid spoke to the BBC and confirmed the group had carried out the attack.
He told AFP news agency that they had "support from inside the naval force for this attack" and would continue targeting security forces.
The BBC's Shahzeb Jillani in Karachi says security experts have long feared the possible penetration of jihadi groups into Pakistan's armed forces, especially the navy.
In recent years, the Pakistani Taliban have carried out a number of high-profile assaults on military installations.
Besides the 2011 attack on the Mehran naval base in Karachi, where Pakistan navy insiders were said to be involved in, they also stormed and briefly occupied the military's headquarters in Rawalpindi in 2009.
Militant attacks inside Pakistan have fallen sharply since June when an army offensive was launched in North Waziristan, which had been a Taliban stronghold.
But on 14 August an army aviation base was attacked in Quetta, with a Pakistani Taliban faction claiming responsibility along with another militant group.
The army offensive followed an attack on Karachi airport, the country's largest, in which at least 28 people, including all 10 attackers, were killed.