Roughly two dozen huge oil tankers are idly turning figure eights around the Mediterranean or on the high seas, loaded with oil pumped from wells in Iraqi Kurdistan but with nowhere to legally offload it.

The oil fleet is a costly gamble, to the tune of millions in fees each month, by Kurdish officials who are desperately trying to sell the oil abroad, even as the Iraqi government and the United States are blocking their attempts.

To Iraqi officials, the tankers are carrying contraband — oil that by law should be marketed only by the Iraqi Oil Ministry, with the profits split: 83 percent for the Baghdad government, 17 percent for the Kurdish autonomous government in the north.

Fearing that Iraqi Kurdistan will use oil profits to fuel a bid for independence, the Iraqi government has threatened to sue any country or company that buys Kurdish oil, and has cut off national funding for the Kurdish region.

The Kurds have kept pumping oil anyway, betting that their American allies, who have pressured them to abide by the Iraqi oil law, will soften their stance, and that buyers will come forward. But as oil prices have plummeted, and as Iraq and the United States have refused to budge, the odds are getting longer by the day.

For now, Kurdish officials are sticking to a long-term view of the confrontation, despite its high cost at a time when the government is all but broke. They believe that, eventually, the oil glut this fall will end, and that international buyers will need Kurdish crude and support their nationalist aspirations.

“The ships going out to the international seas are testing the waters,” said Khalid Salih, a former senior adviser to the Kurdish Ministry of Natural Resources. “Suddenly, you will see and hear breakthroughs.”

American officials who want Kurdistan to remain a part of Iraq, and want the Kurdish peshmerga to keep fighting Islamic State militants where the Iraqi Army cannot, are pressing the two sides to work things out. Negotiations are underway, but officials with knowledge of the talks say in private that little progress has been made.

Kurdish politicians have given the new Iraqi prime minister, Haider al-Abadi, roughly another month to settle, restoring payments and giving them more freedom to market oil, or they will not participate in the Iraqi government. Mr. Abadi has said he is willing to compromise, but so must the Kurds.

Though estimates of Kurdish oil reserves vary widely, the area under Kurdish control is believed to represent about 17 percent of Iraq’s oil reserves of 141 billion barrels.

Kurdistan is exporting at least 280,000 barrels of oil per day through a pipeline to a port and holding facility at Ceyhan, Turkey, where the tankers have been loaded. Kurdish officials say they plan to increase that to a half million barrels a day by the end of the year.

After the Islamic State, also known as ISIS or ISIL, swept through northwestern Iraq in July, the Kurds took control of Kirkuk, a city with the second-largest oil deposits in the country. Kurdish officials have said publicly that they hope to start pumping from those fields, too.

And there are potential buyers, though few have signaled publicly that they are willing to brave American ire and Iraqi legal action to follow through.

In June, several news organizations reported that one tanker offloaded its Kurdish oil at an Israeli port. And Iraqi officials say there have been black-market buyers for Kurdish oil, a tanker truck at a time, in Turkey and Iran, among other places.

Several oil traders who closely watch tanker traffic noted that several of the tankers had occasionally turned off their radio transponders, suggesting that some may be secretly pumping their Kurdish oil onto other tankers — a common oil-smuggling practice. That possibility makes the oil even more difficult to track or quantify.

The Kurdish fields also produce natural gas, another commodity of economic and political importance in the region. Turkey is increasingly dependent on gas for its energy needs, and it hopes to replace expensive Russian and Iranian gas with increasing amounts of cheaper gas piped from neighboring Kurdistan. Kurdish gas also could help Europe to reduce its dependence on Russian energy.

So far the United States and other nations have demurred at the prospect of exporting Kurdish oil and gas, concerned that undercutting Baghdad’s authority will doom attempts to keep the country together.

“The calculus for the United States is to find a solution that allows the Iraqi government as well as the Kurdistan region to gain,” said Carlos Pascual, the former State Department special envoy and coordinator for international energy affairs, who left the post earlier this year.

From the Kurdish perspective, “They are trying to test the market for these exports to see who might take them and at what price,” Mr. Pascual said. “And the question is: Is this a test of marketability of product to be able to increase leverage in negotiations between Erbil and Baghdad, or is this the beginnings of a test to see if they might eventually obtain sufficient revenues to move toward independence?”

Many Iraqi officials are convinced that the Kurds are seizing on the recent crisis, and the longer dispute over oil, to edge closer to independence.

Developments over the past few years, and the statements of Kurdish officials, tend to bear out that view. Kurdistan has plowed through the objections of Baghdad to develop a burgeoning oil industry, inviting companies large and small to explore with generous terms that conflict with those observed in Iraq.

“I think Iraqi Kurdish independence is inevitable, at least eventually,” said Michael Makovsky, a former Pentagon official who dealt with Iraqi energy policy during the George W. Bush administration. “They have natural allies in the United States because of the oil companies involved in drilling there. And the Turks and Europeans need their gas.”

That is the bet that many energy companies are taking, factoring in the Kurds’ vital role in fighting ISIS.

“Everybody needs them to stand up to ISIS, and they need funds to purchase weapons for their self-defense,” said Sadad Ibrahim al-Husseini, former head of exploration and development for Saudi Aramco. “At the end of the day, the Kurds will have their way, because they are the only credible Sunni group that can confront ISIS.”

More than 80 energy companies are now working in Kurdistan, including big names like Chevron and Exxon Mobil. Since 2005, more than 100 wells have been drilled in the Kurdish region, triple the number drilled between 1901 and 2004.

But the progress has now plunged Kurdish and Iraqi officials into an ever-deeper dispute. The more Kurdish officials developed their oil industry, the more Baghdad balked. The more the central government restricted the Kurds, the more they felt like they had no choice but to press forward.

“Their policy is actually backfiring,” said Howri Mansurbeg, a professor of petroleum geosciences at Soran University in Kurdistan, said of Iraqi officials. “They want to prevent a Kurdish state, and now the exact opposite is happening.”

Kurdish officials insist that they are willing to share any oil revenue with the Iraqi government. But at the same time, they proudly admit that their eventual aim is independence.

“If you ask a baby in his cradle, he will say, ‘Independence!’ ” said Ahmed Abdullah Askari, a member of the provincial council in Kirkuk. “Kirkuk will play a great role in our independence.”

Kurdish officials have long claimed Kirkuk as their territory, and they are unlikely to cede the area and its oil fields now that they have full control of them.

“You are guaranteed an economic lifeline for the Kurdish government with Kirkuk, and can make a strong case for independence,” said one oil industry official in Erbil, who spoke on the condition of anonymity because he was not authorized to comment publicly. “With what they have in reserve, without Kirkuk it wouldn’t last more than 20 years.”

For now, Kurdish officials are pumping only about 30,000 barrels of oil a day from Kirkuk — just enough, they say, to keep the machinery running and serve the local communities.

But others also see it as a pointed message to Baghdad. The oil company executive in Erbil said that in effect, Kurdish officials were saying: “We can do this and are doing it and will continue to do it, and there’s nothing you can do to stop us.”