Prime Minister David Cameron announced the deal as he started a Jamaica visit.
The project has been agreed to break the deadlock in negotiations over a prisoner transfer deal between the two countries.
More than 600 Jamaican nationals are in UK jails but cannot be deported because of Jamaica's poor prison conditions.
Officials say the foreign aid-funded deal could save taxpayers £10m a year when transfers begin in 2020.
More than 300 existing offenders are expected to be sent back under the Jamaica prison scheme, which covers those sentenced to at least four years who have 18 months or more left to serve in custody.
Currently they cannot be sent to Jamaica because of fears that jail conditions in the country would allow a successful challenge under human rights law.
Jamaica is third highest in the list of foreign countries with nationals serving prison sentences in the UK..
Almost 70% of the Jamaicans in prison in Britain are serving sentences for violence and drug offences.
The UK is contributing about 40% of the cost of building the planned jail, which would hold 1,500 people.
Mr Cameron, who had been at the United Nations in New York for talks on the fight against the Islamic State group, said: "It is absolutely right that foreign criminals who break our laws are properly punished but this shouldn't be at the expense of the hard-working British taxpayer," he said.
"That's why this agreement is so important. It will mean Jamaican criminals are sent back home to serve their sentences, saving the British guard of honourtaxpayer millions of pounds but still ensuring justice is done.
"And it will help Jamaica by helping to provide a new prison, strengthening their criminal justice system."
Mr Cameron, the first British prime minister to visit the island in 14 years, is also set to announce £300m of aid funding on infrastructure projects across the Caribbean, including roads, bridges and ports.
He said the regional infrastructure fund, which will be delivered in collaboration with the Caribbean Development Bank, would help support economic growth in the Caribbean.
Mr Cameron was greeted on his arrival at Kingston Airport by an honour guard and national anthems before he visited RFA Lyme Bay, the British ship currently on anti-drug smuggling and emergency relief duties in the Caribbean.
He is due to finish the day by having talks with Jamaican Prime Minister Portia Simpson-Miller and attending a reception.
BBC political correspondent Carole Walker says that the PM has said he wants to improve a neglected relationship between the UK and Jamaica.
The UK is to spend £25m on building a prison in Jamaica so that foreign criminals in the UK can be sent home to serve sentences in the Caribbean.