Afghan President Ashraf Ghani speaks during a July news conference in Kabul. (Mohammad Ismail/Reuters)

Afghan President Ashraf Ghani, defying expectations just days after a major Taliban attack on a large Afghan city, announced Sunday afternoon that his government would offer a two-month cease-fire to the insurgents on the condition that they respond positively.

In a live televised address marking Afghanistan’s independence from Britain in 1919, Ghani called on Taliban leaders to “welcome the wishes of Afghans for a long-lasting and real peace” and urged them to prepare for peace talks. He said the truce would go into effect Monday, the eve of a three-day Muslim festival, and last until October, “provided that the Taliban reciprocate.”

There was no immediate response from the Taliban regarding the cease-fire, but its committee on prisoners released a statement Sunday night saying the group would free hundreds of captives who are “fit to be released” during the upcoming Eid al-Adha holiday, during which animals are sacrificed and feasts are held across the Muslim world.

Then on Monday, Taliban forces attacked three buses near the northern city of Kunduz and kidnapped hundreds of passengers. Afghan forces carried out an operation to free them, rescuing 149 people. Another 21 are still believed to be in Taliban hands, with clashes ongoing Monday afternoon.

The Taliban has staged numerous attacks across the country in the past two weeks. The most spectacular was a major ground assault on the city of Ghazni, which left more than 200 dead and buildings in ruins. Fighting raged four days until U.S. airstrikes and Afghan commando reinforcements finally drove out hundreds of insurgents.

Before the Ghazni attack, there were rising hopes for a repeat of a successful three-day truce in June in which insurgent fighters joined civilians and government troops to celebrate the end of Ramadan. But many Afghans had predicted that the spate of attacks would force Ghani to abort widely rumored plans to announce a new cease-fire during the Muslim festival of Eid al-Adha, which begins Tuesday.

Some observers, though, said they thought the Ghazni attack — the most serious assault on an Afghan city since 2015 — was not intended to sabotage peace talks but to give the insurgents an advantage at the negotiating table. Ghani had proposed extending the June cease-fire, but the Taliban did not respond. This time, he made his offer conditional on the group’s acquiescence.

The president said that numerous segments of Afghan society, including Muslim scholars and clerics, political parties, civic groups and members of the government High Peace Council, had called for an end to bloodshed and a negotiated settlement to the 17-year conflict. He asked the insurgents to be ready for talks that would be “based on Islamic values and principles.”

There was no immediate comment from U.S. officials, but they reportedly had urged Ghani to go ahead with his truce offer. After the June cease-fire, a senior State Department official held the first-ever U.S. talks with Taliban officials in Qatar, and Secretary of State Mike Pompeo said earlier this year that the United States would be willing to participate in peace talks.

Taliban leaders have long insisted that they will negotiate only with American officials, not with Afghans. In comments last week, Defense Secretary Jim Mattis suggested that the Ghazni attack was an effort to “up the ante” in peace talks rather than sabotage them.

The government of Pakistan immediately issued a statement welcoming Ghani’s announcement and said it “fully supports all such efforts.” It called on all parties in the conflict to “make a commitment to a cease-fire” similar to the one in June and urged that this time it be extended.

Pakistan, which inaugurated a new prime minister Saturday, has been accused by Afghan and U.S. officials of sheltering Islamist militant groups that attack Afghanistan. After the Ghazni attack, some Afghan officials including Ghani charged that Pakistani fighters had taken part in the battle and that some of their dead and wounded victims had been clandestinely returned to Pakistan for burial or treatment.

Military officials in Pakistan denied the accusations, saying they did not support or have ties with anti-Afghan militant groups. They suggested instead that some Pakistani laborers in the border region might have gotten caught up in the violence and possibly been wounded or killed.

Sayed Salahuddin contributed to this report.