RIO DE JANEIRO — The top executive of Petrobras, Brazil’s state oil company, resigned on Friday, fueling uncertainty about the future of the country’s energy sector, a pillar of Brazil’s economy that has drawn enormous interest from foreign investors in recent years.

The executive, Pedro Parente, the company’s chief executive, had been credited with steadying Petrobras, which was devastated by a corruption scandal in 2014, and restoring foreign investors’ confidence as Brazil emerged from a crippling recession.

But Mr. Parente faced a barrage of political pressure and criticism in recent days as a loosely organized truckers’ strike paralyzed the country for more than a week, leading the government of President Michel Temer to subsidize the cost of diesel at the pump.

Critics said the government’s move represented a return to the type of heavy-handed state meddling in oil prices that Mr. Parente had advised against when he took the helm of the company two years ago.