MOSCOW — The five countries with shorelines on the Caspian Sea agreed on Sunday to a formula for dividing up the world’s largest inland body of water and its potentially vast oil and gas resources.

The leaders of Russia, Iran, Kazakhstan, Azerbaijan and Turkmenistan signed the Convention on the Legal Status of the Caspian Sea, which the Kremlin said in a statement “reflected a balance of interests” of the seashore nations.

Landlocked and less salty than an ocean, the Caspian Sea was regarded by Iran and the Soviet Union — until the Soviet collapse — as a lake, with a border neatly dividing the two countries’ territories.

But when new bordering nations emerged, they sought either their own zones of Caspian territory or a new approach to governing the sea that would classify it as international water with territorial zones and neutral areas.