BRASILIA, July 28 (Reuters) - Brazil's Compass, a unit of energy company Cosan, said in a securities filing on Wednesday that it agreed to buy a 51% stake in natural gas company Gaspetro from state-run oil company Petrobras for 2.03 billion reais ($396.81 million).

Japan's Mitsui & Co owns the remaining 49% in Gaspetro, which is a holding company with interests in 19 distributors of piped natural gas.

In a separate disclosure, Petrobras said the sale was in line with an agreement between the oil firm and the antitrust regulator to sell off natural gas assets. ($1 = 5.1158 reais) (Reporting by Gabriel Araujo; writing by Jake Spring; editing by Chris Reese)