KABUL, Afghanistan — President Ashraf Ghani of Afghanistan declared a brief, unilateral cease-fire with the Taliban on Thursday, a strategic gamble seen as a trust-building measure to encourage the militant group to conduct peace talks even as the war grows deadlier.

The cease-fire, which Mr. Ghani said would go into effect for eight days starting next week to coincide with one of the holiest periods on the Muslim calendar, comes months after his government presented an extensive peace offer to the Taliban.

But just what the cease-fire could mean for the prospect of peace talks was unclear, with the resurgent Taliban dictating the reality on the battlefield and, as a result, any moves toward peace.

“This cease-fire is an opportunity for the Taliban to reflect that their violent campaign is not winning them hearts and minds but further alienating the Afghan people from their cause,” Mr. Ghani said in his announcement.