Judges at The Hague awarded Peru parts of the Pacific Ocean but kept rich fishing grounds in Chilean hands.
At stake were 38,000 square kilometres (14,670 square miles) of ocean and some of the world's richest fishing grounds.
In 2008, Peru asked the International Court of Justice to rule on the matter, saying the border was not legally set.
In its ruling, the UN court gave Peru around 20,000 square kilometres (7,700 square miles) and control over a further 28,000 square kilometres (10,800 square miles) of ocean currently in international waters.
It also said that the maritime border should start from the same point on the coastline as it does now.
Peru wanted the boundary to extend roughly south-west, perpendicular to the point where the two countries' land border meets the ocean.
But Chile insisted it should extend from the coast parallel to the equator. It cited treaties agreed in 1952 and 1954 which it said had settled the maritime boundary on that basis.
Both countries have pledged to abide by The Hague ruling.
Chilean President-elect Michelle Bachelet said she "regretted" what she called a "painful loss" for her country, but promised she would work to "implement the ruling gradually".
Her Peruvian counterpart, Ollanta Humala, said "Peru is pleased with the outcome" of the court decision, and would "take the required actions and measures immediately for its prompt implementation".
Peru's fishing industry estimates that the disputed zone has an annual catch of 565m Peruvian nuevo soles ($200m; Â£121m), particularly of anchovies, which are used to make fishmeal.
Chile has promised financial help to its fishing industry in the event that the court decision affects it adversely.
Correspondents say that, with intense interest in the case in both countries, there was considerable national pride at stake too.
Some Peruvians saw the ruling as a chance to win back national pride and territory, after a humiliating defeat to Chile in the 19th Century.
In the 1879-1883 War of the Pacific, Chile took mineral-rich land from both Peru and Bolivia.
Bolivia lost its only outlet to the sea, and has also instituted proceedings against Chile at the ICJ.
The United Nations' highest court has defined the maritime boundary between Peru and Chile after an acrimonious dispute between the two neighbours.