LONDON, Aug 7 (Reuters) - A surge in tin inventories, weak demand and the risk of speculators selling bullish positions are likely to constrain tin prices rallying further following a mining ban in the world's third biggest tin mining nation Myanmar.

Tin is the strongest performing metal on the London Metal Exchange (LME) this year, rising by 12% so far compared to a 1.4% gain for the next best performer, copper.

The LME tin cash contract is expected to average $25,000 a metric ton in the fourth quarter, down 10% from Monday's close, according to a median forecast of 14 analysts polled by Reuters last month.

Gains were spurred by an announcement in April by Myanmar's ethnic minority Wa militia of a suspension of all work at mines in areas it controls from Aug. 1.

"It's hard to get too excited about the price upside. The fact that it's been well-flagged means there's been opportunity for people to prepare," said Citi analyst Tom Mulqueen.

The Wa militia earns significant revenue from mining so it would be surprising if the ban lasted for more than a few months, he added.

"Our view is that the inventory levels are relatively strong and even if you get a couple months of disruption, the market should be able to absorb that."

The run-up in prices was fuelled by speculative buying, with long positions held by investment funds on the LME more than doubling since April, but moves to lock in profits could weigh on the market, analysts said.

The Myanmar mining ban may dampen Chinese smelter output in the second half of 2023, but analysts note that tin production elsewhere is healthy, having rebounded since January due to gains from Indonesia, Peru and Bolivia.

The world's biggest tin producing company, Indonesia's PT Timah, aims to boost refined tin output by a third this year.

Another factor that may weigh on tin prices is weak global demand since more than half of global tin supply is used as solder for circuit boards for the semiconductor industry.

The world's largest contract chipmaker TSMC recently forecast a drop of around 10% in 2023 sales.

"We suspect this ban on mining will take the sting out of the drag on prices we expect later this year from weakening global electronics demand," Kieran Tompkins, commodities economist at Capital Economics, said in a note.

(Reporting by Eric Onstad Editing by Mark Potter)