CARACAS/HOUSTON - Venezuela's powerful former oil czar Rafael Ramirez said on Tuesday he resigned from his job as U.N. envoy on orders of the president, a sign of growing rifts in the Socialist Party once firmly united under late leader Hugo Chavez.

Sources told Reuters last week that leftist President Nicolas Maduro fired Ramirez, who was thought to have presidential ambitions, and summoned him back to Caracas from New York.

Several close allies of Ramirez, as well as a relative, have been arrested in Venezuela in recent weeks as part of a purge in the oil sector over graft allegations, sparking questions about whether Ramirez would dare return to Caracas.

Ramirez did not discuss his next moves in a resignation letter, but a source close to him told Reuters on Tuesday that had left the United States.

In his four-page letter posted on Twitter, Ramirez said he resigned on Monday after receiving orders to do so.

'I have been removed for my opinions,' Ramirez said.

'By attacking me personally, you are affecting the unity of the revolutionary forces and the legacy of Comandante Chavez,' he added in the letter addressed to Foreign Minister Jorge Arreaza, referring to former Venezuelan leader Hugo Chavez.

The sacking caps a remarkable downfall for Ramirez, who led state oil company PDVSA and the oil ministry for a decade and was one of Chavez' closest confidants. Maduro in 2014 demoted Ramirez and appointed him to the United Nations.

A protracted rivalry between the two men has increased in recent weeks, insiders said, especially after Ramirez wrote online opinion articles criticizing Maduro's handling of Venezuela's tanking economy.