Brazil’s government hailed an agreement to suspend a four-day nationwide truckers’ strike over diesel prices that wreaked havoc on Latin America’s largest economy and sparked major shortages of food and fuel.

Flanked by other senior ministers and union leaders, chief of staff Eliseu Padilha told reporters Thursday evening in Brasilia that the two sides had agreed to call off the strike for 15 days. Diesel prices, which had been adjusted daily according to market rates, will now be fixed for 30 days. The government and state-run oil company Petrobras will split any extra costs. Nine of the 10 unions involved in the job action signed the agreement, Padilha said.

The agreement should end the rapidly-escalating crisis that saw drivers lined up for hours at gas stations, supermarkets ration goods, and flights grounded. But the after-effects of the strike are likely to linger, with all carmakers due to stop production lines Friday and American Airlines scrapping its Miami-Brasilia flight on concern about fuel supplies. The protests also exposed the weakness of lame-duck President Michel Temer’s government as it limps into its last six months in office and highlighted Brazilians’ resistance to market-friendly economic policies.

Authorities proved hard pressed to calm the chaos let loose by the strike that erupted Monday, set off by fuel-price increases of about 50 percent over a year. Temer, who’d like to be remembered as the man who got Brazil back on track after its worst recession, fumbled initial attempts to pacify the situation: Petrobras cut the price of diesel by 10 percent for two weeks, but that retreat spooked investors and also failed to appease the truckers.

The wobbly response spooked investors. Concern that Petrobras was caving to political pressure and might abandon its market-based fuel policy caused the company’s shares to plummet as much as 16 percent, the most in a year. The Sao Paulo stock exchange index fell as much as 2.3 percent Thursday.

Brazil, which is larger than the continental U.S., is specially vulnerable to disruption in transportation. It relies heavily on trucks to move cargo as it has only a small network of railways that cater mostly to shipping raw materials such as iron ore or soybeans.

Finance Minister Eduardo Guardia said that the government would create a subsidy for diesel prices and compensate Petrobras for any losses, allowing the oil company to maintain its market-driven price policy. The deal doesn’t include gasoline.

Petrobras issued a statement describing the agreement as “highly positive.”