Japan's second-largest refiner TonenGeneral Sekiyu KK said on Sunday it will buy 99 percent of the shares in the Exxon Mobil Corp.'s Japanese unit, ExxonMobil Yugen Kaisha, for 302 billion yen ($3.94 billion) to improve efficiency.

Exxon Mobil will give up its controlling stake in TonenGeneral itself, but retain a 22 percent voting share in the Japanese oil giant, completing the transaction by June 1, a statement said.

ExxonMobil currently holds about 50 percent of the Japanese refiner.

TonenGeneral said it has no plans to change a 38 yen per share dividend forecast for 2011, and it expects to maintain the same dividend in 2012.

The deal marks a de facto retreat from the world's third-largest economy by Exxon Mobil, which is focusing its resources on emerging markets and the development of natural resources.

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, analysts have said.

Oil demand in Japan has declined in recent years and the domestic operating environment has been characterized by continuous pressure on both margins and volumes, TonenGeneral said.

The deal is aimed at enabling the group to cope with the challenging environment more effectively, it said.

Reuters reported on Saturday that Exxon Mobil was in talks to sell most of its stake back to TonenGeneral.

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

TonenGeneral will seek funds from the Sumitomo Mitsui Banking Corp., Sumitomo Trust Banking, Bank of Tokyo Mitsubishi UFJ, and Mitsubishi Trust Bank to buy the Exxon Mobil stake, industry sources told Reuters.

($1 = 76.7350 Japanese yen)

(Reporting by Yuko Inoue; Editing by Ed Lane)