The US and conservation groups will cut $26m (£12.8m) from Costa Rican debt in return for the country spending the same sum on forest protection.
Costa Rica's forests are home to a number of endangered species.
Costa Rica will spend the money over the next 16 years on large swathes of its tropical forest.
It hopes to help conserve such endangered species as the jaguar, squirrel monkey and scarlet macaw.
Areas targeted include the Talamanca Highlands that contain the country's largest untouched tract of rainforest.
Environment minister Roberto Dobles told the BBC that the money would help the government enlarge protected areas, support local communities in their conservation efforts, and encourage tourism.
"We in Costa Rica protect four to five per cent of the world's biodiversity, and our territory is much, much smaller than four to five per cent of the global territory," Mr Dobles said.
"So we feel that we are also protecting humanity's biodiversity, so all the support such as this one is always welcome."
The settlement is the largest of its kind reached under the US Tropical Forest Conservation Act, says BBC Americas editor Will Grant.
Guatemala, Belize and Peru have benefited from similar deals in recent years.
Under the plan, the US will contribute $12.6m. A further $3m will be contributed by conservation groups the Nature Conservancy and Conservation International.