KABUL (Reuters) - U.S. Defense Secretary Jim Mattis met Afghan President Ashraf Ghani during an unannounced visit to Kabul on Friday to discuss prospects for peace talks with the Taliban and the country’s deteriorating security situation ahead of upcoming elections.

Mattis was accompanied by Chairman of the Joint Chiefs of Staff Marine General Joseph Dunford, who earlier in the week had gone to Islamabad with Secretary of State Mike Pompeo on a mission to reset testy relations with Pakistan’s new government.

The United States has withheld $800 million of military aid from Pakistan this year, having accused Islamabad of turning a blind eye to, or helping, Afghan Taliban and Haqqani network fighters who stage attacks in Afghanistan. Pakistan denies doing so.

The United States is a year into its latest attempt to step up pressure on the Taliban by increasing air strikes and sending thousands more troops to train and advise the Afghan National Defense and Security Forces (ANDSF).

Meeting Ghani in his presidential palace, the U.S. officials discussed progress to end the 17-year-old war, which has become America’s longest conflict.

“They discussed peace process, positive impact of the South Asia strategy, reforms in ANDSF, upcoming parliamentary and presidential elections, counter-terrorism and dialogue with Pakistan,” Ghani’s official spokesman said in a tweet after the meeting.

Mattis and Dunford also met U.S. Army General Scott Miller assumed command of NATO forces in Afghanistan on Sunday.

As yet, there is little sign yet of Afghanistan becoming more secure and stable before a parliamentary election next month and a presidential election in April.

During recent weeks, the Taliban killed hundreds of soldiers and police and briefly seized the strategic city of Ghazni in a high profile assault.

Speaking with reporters prior to his arrival in Kabul, Mattis said he was hopeful about peace talks with the Taliban, despite the questions over Washington’s strategy in Afghanistan.

“Right now, we have more indications that reconciliation is no longer just a shimmer out there, no longer just a mirage,” Mattis said.

FILE PHOTO: U.S. Defense Secretary James Mattis gestures during a press briefing at the Pentagon in Washington, U.S., May 19, 2017. REUTERS/Yuri Gripas/File Photo

“It now has some framework, there’s some open lines of communication,” Mattis added.

Over the summer, a top U.S. State Department official met Taliban officials in Qatar to try to lay the groundwork for broader peace talks.

The U.S. government has pointed towards the Taliban accepting a temporary truce in June, as a sign of why the talks should be viewed with hope.

“The most important work that has to be done is beginning the political process and reconciliation,” Dunford told reporters traveling with him.

“What we are trying to do in the military dimension is convince the Taliban that they cannot win on the battlefield and that they must engage in a peace process.”

Privately, however U.S. officials and experts are more cautious.

A U.S. official, speaking on the condition of anonymity, said it was unclear how much influence the Taliban officials in Doha, Qatar, had over the group’s leadership.

“I think that both the U.S. and Afghanistan have perhaps exaggerated the good news in Afghanistan,” Michael Kugelman, with the Wilson Center think-tank in Washington.

Two insurgent commanders have told Reuters that the Taliban rejected a second ceasefire offered this month by Ghani.

CREDIBLE NEGOTIATING PARTNER?

The U.S. official who spoke on the condition of anonymity said there were concerns that the Afghan government wasn’t doing enough to create programs for Taliban fighters looking to quit the insurgency.

“If the Afghan government can be more responsive to disgruntled fighters, that would go a long way in creating legitimacy for the peace process,” the official said.

Divisions within the Afghan government could also spoil chances of peace talks.

National Security Adviser Hanif Atmar, one of the most powerful figures in the government, has resigned amid speculation he is preparing to challenge Ghani in next year’s presidential election.

“I would be surprised if anything major happens on the reconciliation front before the presidential election next year because the Taliban simply doesn’t see the government as a credible force,” Kugelman said.

Any talks would not include the Islamic State militant group, which claimed credit for a suicide attack at a wrestling club in the Kabul that killed at least 20 people on Wednesday.

The Taliban also opposes the Islamic State in Afghanistan, and Mattis noted that provided rare common ground with the Western forces and the Afghan government.

“Both the Taliban and the NATO alliance supporting the Afghan government view ISIS in the same light,” Mattis said.