THE HAGUE (Reuter) - The International Court of Justice, ruling on a long-standing dispute between Hungary and Slovakia, said on Thursday that both countries had breached a 1977 treaty on harnessing the river Danube to generate electricity. In its first major environmental case, the United Nations court said Hungary had been wrong to withdraw from the treaty and abandon work on the project. But it said Slovakia had also acted unlawfully by pressing ahead with the project on its own and unilaterally diverting the course of Europe`s longest river. "In the judgment, the court has concluded that both parties committed internationally wrongful acts," presiding judge Stephen Schwebel of the United States said. The plan to exploit the Danube for hydro-electric power started out as a joint project in 1977 between the then communist governments of Czechoslovakia and Hungary and envisaged the building of twin dams, one in each country. Budapest stopped work on its own dam in 1989 under pressure from environmental groups and in 1992 it abandoned the project altogether. But Czechoslovakia completed its part of the works which were taken over by Slovakia after its secession in 1993. The court ordered Hungary and Slovakia to negotiate in good faith to achieve the original objectives of the 1977 treaty and agree on a joint operational regime for the Slovak works. It said each country had damaged the other`s interests and both were obliged to pay compensation, though it suggested the competing claims could be dropped under a broader settlement. "The issue of compensation could satisfactorily be resolved in the framework of an overall settlement if each of the parties were to renounce or cancel all financial claims...," it said. During hearings on the case earlier this year Hungary argued that Slovakia had illegally enriched itself by unilaterally diverting the river, wreaking havoc on flora and fauna in the border area and depriving Hungarians of vital water resources. Slovakia insisted Hungary was at fault for failing to honour its treaty obligations and said Budapest had raised environmental issues to obscure the underlying legal dispute. The court said newly developed norms of environmental law were relevant to the implementation of the 1977 treaty and could be incorporated into it by mutual agreement. To reconcile economic development with protection of the environment it called on the two countries to take a fresh look at the environmental effects of the Slovak power plant. The International Court of Justice, set up as a United Nations body in 1945, acts as a world court, resolving disputes between states that have accepted its jurisdiction. Its decisions are binding, final and without appeal and ultimately enforceable by the U.N. Security Council.