JALALABAD, Afghanistan — A remarkable thing happened in Afghanistan’s war. There were nearly two days of peace.

As cease-fires by the government and the Taliban took hold, security forces and insurgents celebrated and took pictures together for the Muslim festival of Eid al-Fitr, marking the end of the holy fasting month of Ramadan.

But at one of those celebrations in the eastern province of Nangarhar, an explosion went off Saturday afternoon, killing at least 36 people and wounding more than 65, among them civilians and members of both the Taliban and the Afghan security forces. Officials said it was either a suicide bomber or a car bomb.

Dozens of Afghan troops were being killed every day in the run-up to the cease-fires, raising doubts about whether a sudden cessation of fighting would take hold. But for much of Friday and Saturday, Afghans were happily surprised, stunned even, by how widely the truces had been embraced.

The blast that took casualties from both sides was a reminder of how complex the Afghan war remains. Even the smallest steps to build trust for peace negotiations are vulnerable to spoilers.

An offshoot of the Islamic State, which has had a foothold in the province and has been behind some of the deadliest recent attacks there, claimed responsibility for the attack outside the provincial capital of Jalalabad, according to the tracking group Terror Monitor.

The Islamic State in Afghanistan, which claims allegiance to the global terrorist group, is largely made up of former Pakistani and Afghan Taliban. Afghan and American officials have struggled to pin down how closely it coordinates with the international group. The local branch has fought the Taliban in some areas, but in other places it has coexisted and even cooperated with the insurgents.

Attaullah Khogyani, a spokesman for the governor of Nangarhar, said the explosion was caused by a suicide bomber. But Lal Mohammad Durani, the deputy speaker of the provincial council in Nangarhar, said it was a car bomb.

News of the bombing came just as President Ashraf Ghani, in a televised address, offered to extend his government’s eight-day unilateral cease-fire, which is set to end on Tuesday. An overlapping Taliban cease-fire was for the three days of Eid.

After Mr. Ghani’s address, Secretary of State Mike Pompeo hinted at a more prominent role for the United States in talks with the Taliban and a willingness to discuss the status of foreign troops, issues that many consider central to starting peace talks.

“As President Ghani emphasized in his statement to the Afghan people, peace talks by necessity would include a discussion of the role of international actors and forces,” Mr. Pompeo said. “The United States is prepared to support, facilitate and participate in these discussions.”

In describing their perspective on peace talks, the Taliban have repeatedly brought up the presence of foreign forces and have said they want to talk to the Americans rather than the Afghan government. In recent months, some efforts seem to be underway to include both the Afghan government and the Americans at the table.

The sudden drop in violence not only gave Afghans a glimpse of normal life, it also showed how weary those on both sides have become.

In many cities, Taliban fighters left their weapons at the gates when they went to Eid celebrations.

In the city of Kunduz, which fell to the insurgents twice briefly over the past couple years, they came with weapons. Yet there were remarkable scenes of happiness and chaos.

Hundreds of militants re-entered the city with the weapons and vehicles they had seized from Afghan security forces the last time they overran the city. This time, fighters from both sides greeted each other, even embracing at times.

“It was a real Eid of peace — no one was expecting such a day,” said Rozee Mohammed Zabuli, a civil society activist in Zabul Province, where the Taliban and Afghan security forces mingled in the provincial center as well as many districts. “I was very surprised when I saw Taliban and security forces posing together for pictures.”