JAKARTA- Indonesia's state oil and gas company PT Pertamina said on Monday it had stopped an underwater leak from an oil well off West Java over the weekend after more than two months of spillages.

The company aims to permanently plug the leak next week, but the clean-up effort for beaches nearby is expected to last until at least March next year.

The spill, from the YYA-1 well in Pertamina's Offshore North West Java (ONWJ) block, started on July 12 and was declared an emergency three days later. An environmental group said the spill has affected at least 13 villages, threatening the livelihoods and health of thousands of people.

On Monday, Dharmawan Samsu, Pertamina's upstream director, told reporters that Pertamina had connected a relief well, which should contain the leak, and aimed to permanently plug the leaking well by Oct. 1.

"With this completion, we can soon focus on recovery efforts for the affected area," he said. "We will renovate public infrastructure and clean the environment to restore the ecosystem."

More than 42,000 barrels of oil have been recovered offshore since the spill, Taufik Adityawarman, a Pertamina official said, as well as 5.7 million bags of mixed sand and oil from beaches.

Pertamina has promised to compensate residents affected by the spill, mostly fishermen from villages near the well. Adityawarman said so far only 30% of the compensation money has been distributed.

The company has estimated output from the ONWJ block this year of 29,000-30,000 barrels of oil per day and 110 million standard cubic feet of natural gas per day.

(Reporting by Wilda Asmarini; Writing by Fransiska Nangoy; Editing by Alex Richardson) ((Fransiska.Nangoy@thomsonreuters.com; +62 21 2992 7610; Reuters Messaging: fransiska.nangoy.thomsonreuters.com@reuters.net))