Correction to this article

IT IS what passes for a winter's day in upstate São Paulo. The sun is blazing from a blue sky feathered lightly with cirrus cloud. In a large, sloping field overlooking the city of Piracicaba, a mechanical harvester chomps through a stand of three-metre-high sugar cane, fat and juicy from months of sunshine. The harvester slices the cane into 20cm chunks and regurgitates them into a 30-tonne trailer moving alongside that will lug them a few kilometres to the Costa Pinto mill (pictured). There the cane is weighed, washed, tipped onto a conveyor belt, crushed and then, depending on market conditions, crystallised into sugar or distilled into ethanol. The woody residue—the bagaço—is burned in two high-pressure boilers that, according to the flickering needle in the control room, are supplying around 50 megawatts (MW) of electricity to the local grid—enough to power half of Piracicaba.

Sugar has been grown in Brazil for 500 years, and the country is by far the world's biggest exporter of it. But sugar now also forms the nucleus of a new agro-industrial and renewable-energy complex. Biofuels, mainly derived from sugar, are Brazil's most important source of energy after oil. For a unit of energy, the production and use of sugar-based ethanol generates only two-fifths of the carbon emissions of petrol, and half those of corn-based ethanol, according to the United States Environmental Protection Agency. And bioplastics made from sugar cane are poised to move from the laboratory to the corner store, with the launch of soft-drink bottles.

Yet the industry is struggling to turn all these economic and environmental benefits into reliable revenues. For that it largely blames the government and is duly arguing for a more favourable regulatory regime. But it should watch out. The government, in turn, accuses the industry of wanting to have the best of both the agricultural and energy worlds. It could yet make the industry's life harder.

Since Brazil relaxed price and production controls on sugar cane two decades ago, its crop has increased by two and a half times. Nearly all the growth has come from large, mechanised farms in the south-central region—hundreds of miles away from the Amazon rainforest. Ethanol output has more than doubled since 2002, thanks to the development of flex-fuel engines for cars, capable of running on either petrol or ethanol indistinguishably. More than half the cars in Brazil now have flex-fuel engines, and that figure should rise to 90% by 2017, according to Marcos Jank of UNICA, the sugar-industry association in São Paulo. In addition, Brazil's government requires petrol to be sold in a blend of three or four parts to one of ethanol.

Given its environmental benefits, sugar-based ethanol has the potential to be a global industry. That is why Royal Dutch Shell has set up a $12 billion joint venture with Cosan, Brazil's biggest sugar and ethanol producer. The new venture, signed on August 25th, combines the two companies' service stations in Brazil, totalling 4,500. Shell is also contributing $1.6 billion in cash and its stakes in biofuel-research companies, while Cosan is putting in its 23 sugar mills, including Costa Pinto.

But whereas Brazil exports 70% of its sugar production, 75% of its ethanol output is still sold at home. That is mainly because the United States and Europe see ethanol as an agricultural commodity and protect their own producers (mainly of corn ethanol). Developing an internationally agreed mechanism to certify the environmental benefit would also help, says Mark Lyra, of Cosan. Nevertheless, Mr Jank thinks the world market for Brazilian ethanol will grow—and that the sugar industry can triple its electricity co-generation capacity to 15,000MW (around 27% of Brazil's demand today) from its present acreage of cane.

Realising this potential requires big capital investments. Large-scale exports depend on new pipelines and a port. Three out of four sugar mills are not connected to the electricity grid. But many companies took on debt to expand just before the recession temporarily drove down prices in 2008-09. The result is a gentle wave of consolidation: 87 of the 438 mills in south-central Brazil changed hands last year, UNICA says. Even so, the top five producers still account for barely a fifth of total output.

Until a world ethanol market takes off, Brazil's producers will stay uncomfortably dependent on domestic sales and on Petrobras, the national oil giant. The company is both their biggest customer (because it buys ethanol to mix with petrol) and their top competitor (because its petrol competes with all-ethanol biofuels). It is also the fourth-biggest ethanol producer itself.

The sugar people complain that, although the price of ethanol rises and falls with world sugar demand, petrol prices in Brazil do not adjust quickly to changes in the oil price. They also think that on environmental grounds ethanol should be lower-rated for value-added tax than diesel, as it is in São Paulo but not in other states. And they complain that regulation hampers their expansion. Ethanol and electricity co-generation could make up more of Brazil's energy matrix, argues Mr Jank. “But the long-term future of the ethanol industry depends on government policies,” he says.

These complaints get short shrift in Brasília. Officials complain that when the world sugar price is high—as it is today—the mills divert cane away from producing ethanol. To ensure stable supplies, ethanol should be regulated as a fuel by the National Petroleum Agency, says Tereza Campelo, an official on the staff of President Luiz Inácio Lula da Silva. She accuses the industry of wanting to have all the advantages of being treated as an energy producer and none of the disadvantages.

Two things overhang this debate. The first is new discoveries that have the potential to make Brazil a big oil exporter. The industry says they will make Petrobras even more powerful, and have caused Lula to forget his earlier enthusiasm for biofuels. This last charge seems unfair: the government insists biofuels will retain their current share of Brazil's energy matrix.

Second, if the opinion polls are right, Brazil's presidential election in October is likely to be won by Dilma Rousseff, Lula's former chief of staff and energy minister. She believes even more strongly than he in state planning and direction of the energy industry. The sugar people, by contrast, prefer to follow the market's signals in deciding whether cane is crystallised or distilled. After all, they argue, it was only once the state relaxed its grip that a world-beating ethanol industry came into being.