Brasília (AFP) - A Supreme Court judge on Thursday ordered Brazil's state oil giant Petrobras to refuel two Iranian ships stranded off the country's coast, a source involved in the dispute and a report said.

The order came after Iran's top envoy to Brazil told Bloomberg that Tehran could suspend imports from the Latin American country if the issue was not resolved.

Petrobras has refused to provide fuel to the vessels, which have been stuck at Paranagua port in the southern state of Parana since early last month, for fear of breaching US sanctions.

Washington has imposed a raft of punitive measures on Tehran and companies with ties to the Islamic republic since President Donald Trump pulled the United States out of a landmark multinational nuclear pact last year.

The vessels had reportedly brought urea, which is used to make fertilizer, to Brazil and were to transport corn back to Iran.

Supreme Court Justice Dias Toffoli issued the refueling order behind closed doors Thursday, G1 news site reported, overturning an earlier decision.

AFP was not able to confirm the ruling with the court, but a source involved in the dispute who is not authorized to speak to the media confirmed Petrobras had been ordered to refuel the ships.

Petrobras said it had not yet received the court order when contacted by AFP.

Iran's ambassador to Brazil, Seyed Ali Saghaeyan, told Bloomberg it was up to Brazil to solve the issue, "not the Iranians."

"If it's not solved, maybe the authorities in Tehran may want to take some decision because this is a free market and other countries are available."

The ships Bavand and Termeh reportedly belong to Iranian company Sapid Shipping.

Petrobras said last week it had refused to provide fuel "to the exporting company because the Iranian vessels it contracted and the Iranian company that owns those vessels are sanctioned by the United States."

"If Petrobras were to supply these vessels, it would be subject to the risk of being included in the same list, which could cause serious damages to the company," it said in a statement.

"It should be noted that there are other fuel suppliers in the country," it added.

Petrobras is listed in New York and Sao Paulo.