The deaths come a week before talks seen as vital to averting a war and amid a sudden increase in attacks.
Violence in December and January threatened to shatter a 2002 ceasefire, but tensions had fallen after the two sides agreed to hold talks in Switzerland. However, a rapid rise in violence in the past week is seen as putting the peace process in jeopardy.
Commander DKP Dassanayake, a navy spokesman, said: "There are 12 dead and eight injured. It was a claymore attack."
He said the attack took place near the northeastern port of Trincomalee.
The armed forces blamed the Liberation Tigers of Tamil Eelam (LTTE). The Tigers are accused of a similar attack in northern Sri Lanka on Monday that killed seven. The rebels have denied involvement in that attack, but few analysts believe them.
Claymore mines are blocks of plastic explosive that blast a hail of steel towards their target when detonated by remote control. The army says they have been a favourite Tiger tool in ambushes of military vehicles and patrols.
Tuesday's attack is the most serious on the military since early January, when 13 sailors were killed after the suspected sinking of a naval patrol boat off the Trincomalee post.
The next round of talks is due to take place in Geneva between April 19 and 21, but the rebels have yet to say if they will attend.
They demand that the government honours a pledge made at the first round of talks to stop other Tamil armed groups, operating from army territory, from attacking them.
They also say they want the military to allow senior rebel commanders to travel by sea from eastern rebel areas to the Tiger headquarters for a meeting before the Geneva talks take place.