BAGHDAD—An oil-sales deal between Iraq and the semiautonomous Kurdistan Regional Government is close to collapse about six months after it was signed, undermining the country’s unity as it struggles to fight Islamic State and contain an escalating financial crisis.

Months of acrimony between Baghdad and Erbil, the KRG’s capital, came to a head in June, when the Kurdish side reduced the amount of oil it sold through Iraq’s state-owned Oil Marketing Company, known as SOMO, and began ramping up its independent sales of oil through...