SAO PAULO, July 14 (Reuters) - New legislation approved by the Brazilian Congress late on Wednesday reinstates a tax advantage to biofuels compared to fossil fuels, which should benefit companies producing ethanol and biodiesel in the long-term, analysts said on Thursday.

Brazil's lower house approved the government-sponsored bill that among other things includes a provision saying biofuels should enjoy lower taxes than fossil fuels for a period of 20 years.

The bill added that states and the federal government should go back to preferential taxation levels to biofuels seen before May 15, when another law had changed the way fuels were to be taxed.

"From our perspective, this measure is very positive for agribusiness companies, as it will maintain competitiveness of biofuels in the long term," Citi analysts Gabriel Barra and Joaquim Alves Atie said in a research note.

"With a constitutional guarantee that renewable fuels will pay lower taxes relative to fossil fuels (recognizing fossil fuels' negative externalities), ethanol and other biofuels could enjoy a much stronger outlook ahead," said investment bank BTG Pactual in a report.

BTG said Brazilian mills will be able to be more profitable on their ethanol sales with the new legislation and gave a "buy" recommendation for companies whose shares were previously hurt by the changes made in May, such as Raizen, Sao Martinho, Jalles Machado and Adecoagro .

The May tax modifications ended up reducing ethanol's competitiveness against gasoline at the pump, and pressured sugar prices on the international market as mills started to make less ethanol and more sugar.

That trend, according to the analysts, could now be reverted. (Reporting by Rafaella Barros and Marcelo Teixeira; Editing by Chris Reese)