U.S. oil group ExxonMobil is in talks to sell most of its 50 percent stake in Japanese refiner TonenGeneral Sekiyu KK <5012.T>, in a deal that could be worth as much as $5 billion, four sources with knowledge of the matter said.

The talks see Exxon belatedly join international oil and gas industry peers in scaling back downstream activities such as crude processing and fuel marketing, to focus on more lucrative activities -- finding and pumping oil and gas.

The move could also spark realignment among Japan's oil refiners, which have been cutting capacity to cope with falling demand caused by a weak economy and a shift to more efficient and environmentally friendly forms of energy.

TonenGeneral, which imports and distributes Exxon oil in Japan, ranks as the country's No. 2 refiner behind JX Holdings <5020.T>. Smaller rivals include Idemitsu Kosan Co <5019.T>, Cosmo Oil <5007.T> and Showa Shell <5002.T>.

If this report is true, it could open the door for TonenGeneral to realign in alliance with another company. That may or may not include capital ties, said Hidetoshi Shioda, senior analyst at SMBC Nikko Securities.

CAPITAL RELATIONSHIP

Royal Dutch Shell , BP and Chevron have sold, closed or put up for sale many refineries in the past decade.

Exxon, the world's largest publicly traded oil company by market value, has long been a strong advocate of the integrated oil model, in which companies are active in every stage of the business from well head to forecourt.

The planned sale may be an acknowledgement of a widely held view that in markets with slow-growing or falling fuel demand such as Japan and Europe, refining investments will struggle to offer good returns.

ConocoPhillips, the third-largest U.S. oil major, last year decided to spin off its refining operations into a separate company.

Exxonholds 50.02 percent of TonenGeneral, a stake worth 224 billion yen ($2.9 billion) at Wednesday's close. It also owns a sales network of around 4,000 gas stations across Japan.

Exxon is planning to keep a certain level of ownership in TonenGeneral, seen as key to maintaining the refining partnership, according to the sources, who spoke on condition of anonymity as the talks are still ongoing.

The cost of the deal could climb to as high as 400 billion yen, but may settle at a lower price depending on the size of the stake to be sold, negotiations over the other assets, and TonenGeneral's funding situation, the sources said.

An official announcement could come as early as this month, they said.

TonenGeneral said in a statement that ExxonMobil was considering a change to its capital relationship with TonenGeneral, but nothing had been decided. Exxon stressed it had no plans to withdraw from Japan.

ExxonMobil has no plans to exit the Japan market. We have been doing business in Japan for over 118 years, the oil giant said in a statement to Reuters.

FUNDING BURDEN

Shares of TonenGeneral fell 5.8 percent to 792 yen, its lowest close in 14 months, reflecting investor worries over the burden the deal would place on its finances. Trading in the shares was the busiest in at least 24 years.

TonenGeneral plans to borrow money from several banks to finance the purchase, the sources said.

It is hard to see the strategic direction of TonenGeneral after it buys the assets from Exxon. A deal in the order of 400 billion yen would also strain its cash situation and raise the risk of lower dividends, said Yoshihiro Okumura, head of research at Chibagin Asset Management.

Oil demand in Japan, the world's No.3 consumer, has been falling steadily for more than a decade, to about 3.4 million barrels per day (bpd) from a record 4.2 million bpd in 1999.

That slide has accelerated following a devastating earthquake and tsunami in March, which dented economic activity and prompted some manufacturers to shift factories abroad.

Industry sources had said Exxon might look to scale back in Japan after the country introduced new regulations in 2010, with a 2014 deadline for refiners to boost their ability to process heavy oil by building new cracking units or scrapping capacity.

The directive was seen as particularly burdensome for TonenGeneral due to its relatively low heavy oil processing capacity. The Exxon unit has been a vocal critic of the scheme, calling it unnecessary meddling by the government.

Despite the unfavorable operating environment in Japan, the relationship with TonenGeneral serves an important strategic purpose for Exxon, making it unlikely that it would look at a complete withdrawal, some analysts said.

If ExxonMobil pulled out, they would lose a good outlet, and they could no longer ask TonenGeneral to import ExxonMobil's equity crudes, independent oil economist Osamu Fujisawa said.

($1 = 76.7500 yen)

(Additional reporting by Osamu Tsukimori and James Topham in Tokyo, and Tom Bergin in London; Writing by Nathan Layne; Editing by Chris Gallagher and Will Waterman)