The International Court of Justice ordered Pakistan on Wednesday to review the death sentence for an alleged Indian spy, in a ruling hailed by nuclear rival New Delhi as a "complete victory".

Former Indian navy officer Kulbhushan Sudhir Jadhav was arrested in Pakistan's restive southwestern province of Baluchistan in March 2016, and the case has stoked tensions between the two countries.

Judges at the UN's top court ruled Pakistan had breached the Vienna Convention on diplomatic relations, which gives countries the right to consular access when their nationals are arrested abroad.

The Hague-based ICJ ordered the "effective review and reconsideration of the conviction and sentence" passed on Jadhav, according to a document on the court's website.

Pakistan "deprived the Republic of India of the right to communicate with and have access to Mr Kulbhushan Sudhir Jadhav, to visit him in detention and to arrange for his legal representation", the judges said.

"A continued stay of execution constitutes an indispensable condition" for the review of the death sentence, it added.

India hailed the ruling as a "complete victory."

"By ordering Pakistan to follow the Vienna Convention this is a complete victory for us. This opens up the possibility of consular access and a retrial in a civilian court," an Indian government official said.

"If Pakistan wants improved relations it should set him free and give him safe passage back to us."

There was no immediate reaction from Islamabad.

Jadhav, 48, was sentenced to death by a closed Pakistani military court in 2017 on charges of "espionage, sabotage and terrorism".

- 'Farcical case' -

Jadhav was accused of working for the Indian intelligence services in Baluchistan, a province bordering Afghanistan, where Islamabad has long accused India of backing separatist rebels.

In February Pakistan's attorney general told the ICJ that Jadhav's "unlawful activities were directed at creating anarchy in Pakistan and particularly targeted the China-Pakistan corridor."

Story continues

China and Pakistan are close allies and Beijing has funded a huge port at Gwadar on the Baluchistan coast.

India insists that Jadhav was not a spy and says he was kidnapped in Pakistan.

India's lawyers told the court in February that it was a "farcical case" based on "malicious propaganda".

The last hearing coincided with a sharp spike in tensions between the two nuclear-armed neighbours after a suicide bombing in restive Kashmir, although relations have since improved.

The ICJ was set up in 1946 to rule in disputes between countries.

The court has already intervened previously in the case, issuing an urgent order in 2017 telling Pakistan to stay Jadhav's execution while it dealt with the issue in more detail.

New Delhi alleged that Islamabad violated the Vienna Convention by failing to provide him with consular access, as well as breaking human rights law.

India has also accused Pakistan of harassing Jadhav's family in 2017 during a meeting that was held in an "atmosphere of coercion".

It said Jadhav's conversation with his mother and wife was "tutored and designed to perpetuate the false narrative of his alleged activities in Pakistan."

The two neighbours -- who have fought three wars since independence from Britain in 1947 -- routinely accuse one another of sending spies into their countries.

Jadhav joined India's prestigious National Defence Academy in 1987 and was commissioned as an engineer in the Indian Navy in 1991 before reportedly starting a business in Iran.