Foreign Office Minister Alistair Burt said attacks in the region were falling but the position was “fragile and reversible”.
The money will go to the UN Office on Drugs and Crime’s counter piracy programme.
It will be used to improve prison infrastructure and tackle corruption in the Somali penal system.
In a written ministerial statement, Mr Burt said: “Last year saw a dramatic decline in pirate attacks off the coast of Somalia – to just 35 – with the number of ships seized falling by over 80% compared to the previous year.
“This has not occurred by chance. It is the culmination of years of hard work from governments, international organisations and industry.
“Nevertheless, it is by no means ‘mission accomplished’.
“Progress is fragile and reversible – 108 hostages remain in pirate hands, often subjected to terrible conditions with no knowledge of when, or even if, they will be released. So we must stay the course; take the opportunity to press home our advantage and make the waters off the coast of Somalia safe once again.”
The funding will be used to finish a new prison in Garowe, Puntland, to hold convicted pirates in facilities that meet international standards as well as supporting a project to tackle corruption in the Somali penal system.
It will also be used to develop Somali coastguard capability.
Mr Burt warned that piracy was not confined to Somalia and there had been a “worrying increase” in the Gulf of Guinea, off the coast of West Africa, which the government is also tackling with international partners.
Mr Burt added: “We have demonstrated that when we work together we can thwart the intentions of those who would use threats and violence to extract financial gain. If we remain steadfast, we can eliminate the scourge of piracy from our seas.”