Land-locked Bolivia is getting a tiny sliver of the Pacific – a dock, a free-trade zone and the right to run some naval vessels, although the agreement signed with Peru falls far short of what Bolivians have dreamed of for 126 years – a coastline of their own.
Peru's president Alan Garcia announced the pact during a ceremony at the southern Peruvian port of Ilo. It is part of a longstanding crusade by both Peru and Bolivia to prod neighbouring Chile into giving back some of the territory it seized in the 19th-century War of the Pacific.
"It is unjust that Bolivia has no sovereign outlet to the ocean," Mr Garcia said, with Bolivian president Evo Morales at his side. "This is also a Bolivian sea."
Mr Morales said the agreement gave Bolivia a gateway to export its products and he vowed that "Bolivia, sooner or later, will return to the sea".
Peru first granted Bolivia use of a five-kilometre (three-mile) strip of beach in 1992, but the declaration was largely symbolic: Bolivia never managed to use it due to lack of transportation links and infrastructure.
Widely touted plans for a Bolivian natural gas line to Ilo and a Brazil-Bolivia-Ilo highway evaporated. Under the new 99-year deal, Peru is granting Bolivia dock facilities, a free-trade zone and space for economic activities. It can also build a Pacific Coast annex for the Bolivian navy school, which until now largely has been limited to rivers and Lake Titicaca.
Peruvian Foreign Minister Jose Antonio Garcia Belaunde told Radioprogramas radio that the agreement let Bolivia own property in the zone, dropping a prohibition in the 1992 pact.
Chile's victory in the 1879-1884 war gave it mineral-rich territories once held by Peru and Boliva, and the three neighbours have since engaged in constant territorial feuding. Bolivia has repeatedly tried to persuade Chile to grant it a corridor to the Pacific, but polls show most Chileans oppose such a concession. Peru has its own dispute with Chile over sea boundaries.
Tuesday's embraces marked a sharp departure from insults exchanged in the past between the market-oriented Mr Garcia and the socialist Mr Morales.
Only two years ago, Mr Morales suggested that Mr Garcia was "fat and not very anti-imperialist." Mr Garcia suggested Mr Morales "shut up".
Garcia said the meeting ended all the rancour: "Words are carried away by the wind but the brotherhood of peoples... remains forever."