U.S. Secretary of State John Kerry arrived late Thursday on an unannounced visit to Afghanistan as the situation continues to deteriorate between the two presidential candidates who are disputing the June runoff election ballots and are failing to compromise on a hastily brokered agreement Kerry arranged last month, TheBlaze has learned.

Kerry’s arrival comes on the heals of a deadly insider attack by an Afghan solider that ended the life of  Maj. Gen. Harold Green and injured 15 others. The attack, which took place Tuesday at the Marshall Fahim National Defense University in Kabul, comes as the U.S. is preparing to drawdown forces by the end of the year from the country. Greene, who arrived in January and was charged with transitioning the country over to the Afghan military, is the highest ranking senior officer too be killed in combat during the 13-year war. The shooter was killed in the attack.

Afghan presidential candidate Abdullah Abdullah, center, shakes hands with U.S. Secretary of State John Kerry at the start of a meeting at the U.S. Embassy in Kabul, Friday, July 11, 2014. Kerry sought Friday to broker a deal between Afghanistan's rival presidential candidates as a bitter dispute over last month's runoff election risked spiraling out of control. (AP Photo/Jim Bourg, Pool) AP Photo/Jim Bourg, Pool

Afghan presidential candidate Abdullah Abdullah, center, shakes hands with U.S. Secretary of State John Kerry at the start of a meeting at the U.S. Embassy in Kabul, Friday, July 11, 2014. Kerry sought Friday to broker a deal between Afghanistan’s rival presidential candidates as a bitter dispute over last month’s runoff election risked spiraling out of control. (AP Photo/Jim Bourg, Pool) AP Photo/Jim Bourg, Pool

The two presidential candidates, former Afghan Foreign Minister Abdullah Abdullah and former Finance Minister Ashraf Ghani, have been “at each other’s throats over the election that everyone knows has been mired in fraud,” said a U.S. Official with knowledge of the crisis.”The situation in Afghanistan is falling apart and moral is definitely low after Green’s death.

“This is going to be a tough situation for Kerry and [any deal] won’t not be easily brokered,” the official added.

Last month, TheBlaze reported that Kerry delivered an ultimatum from the White House threatening to withdraw all troops from the country by summer’s end if the candidates couldn’t agree to a compromise that would allow the establishment of a new government by early September. Currently, former President Hamid Karzai has been acting as the interim government until the dispute can be resolved.

The urgency worked for only several days and shortly after Kerry departed Afghanistan last month Ghani and Abdullah “were back at each other’s throats,” a former senior Afghan official told TheBlaze. Kerry was scheduled to arrive in Afghanistan last week to meet with Abdullah and Ghani but abruptly cancelled his trip. Instead, Kerry published an opinion editorial that essentially put the full responsibility of resolving the crisis in the hands of the feuding Afghan leaders and would essentially “absolve the Obama administration” from the growing crisis.

“Not in a million years will I understand the mixed signals and inconsistent messaging from this administration, specially when the situation in Afghanistan is so fragile,” the senior Afghan source said.

Kerry’s second visit comes as the Independent Election Commission is hand counting 8.1 million runoff election ballots kept in 23,000 ballot boxes. Kerry’s brokered deal would establish a national unity government whereby the winner becomes president and the runner up takes a newly created post of chief executive.

The deal also requires the president to hold a traditional gathering of elders and politicians in two years, known as a loya jirga, where Afghan officials will vote to create a prime minister position in the cabinet. The position, however, would not usurp the president’s power.

But Ghani and Abdullah can’t agree on the technical details of the current ballot audit being conducted, or the exact power-sharing terms under a unity government and both men differ sharply on whether to reconcile with the Taliban.

Kerry wants to broker the deal and see a president in the position before the upcoming NATO summit in Wales Sept. 4. NATO leaders will be deciding their future role in Afghanistan and determining how to best handle relations after the majority of troops withdraw.

You can follow Sara A. Carter (@SaraCarterDC) on Twitter.