KABUL, Afghanistan — It was an unusually pleasant fall day, and the two Kabul University students joked that they could afford to be a bit late to class to catch some sun.
The students, Ahmad Ali Mohammedi and Sajat Naijati, then headed to their classrooms. Mr. Mohammedi, 25, took the stairs to the second floor of the university’s National Legal Training Center. Mr. Naijati, 21, walked to his on the first floor.
In less than an hour on Monday morning, those locations would decide which of them would survive.
Mr. Mohammedi was shot and killed after gunmen burst into his classroom. Mr. Naijati clambered from the window on the floor below, cutting his face and bruising his head and nose, before sprinting to safety.
At least 21 others were killed and dozens wounded as the attackers barricaded themselves in classrooms, took hostages and systematically tried to kill the future of Afghanistan, a country that, after 40 years of war, stalled peace negotiations and political infighting, has been all but incapacitated by surging violence.
“We didn’t look back,” said Mr. Naijati, 21, who was sitting at home, his head bandaged and a dark purple bruise under his eye. “We ran to save ourselves.”
The fate of the two companions, decided by a few yards and a class schedule, is one endlessly replicated by the war in Afghanistan. Just over a week ago, a suicide bomber killed more than 40 people outside an education center just miles away from Kabul University, the country’s oldest and largest academic institution with roughly 25,000 students. On Tuesday, Afghanistan declared a national day of mourning.
Mr. Mohammedi was buried — his body facing toward where the sun sets among the brown mountains that skirt the city — in a small unassuming cemetery in a poor neighborhood of west Kabul.
Men wept as he was interred, his brother wailing as he was carried to a nearby car to rest.
Mustafa Sorush, a neighborhood friend, quietly looked on.
“He died with all our hopes,” Mr. Sorush, 31, said.
Mr. Mohammedi was in his final year of studies in public policy, with an ambition to attend Stanford or Harvard, Mr. Naijati said. His portrait, with jet-black hair and pensive brown eyes, was affixed to his headstone with clear packing tape.
The attacks on schools in the country’s capital, already riddled with uncertainty as American forces slowly withdraw under a deal with the Taliban, seemed to catapult many Kabul inhabitants into a mood of despair and exhaustion, as if any hope of peace had been erased by Monday’s carnage.
On an early morning call-show on Arman FM, a radio station usually dedicated to local issues like power outages and garbage collection, callers spoke only of the university attack.
“Today is one of those days where you can’t find words,” said Massoud Sanjar, one of the show’s hosts.
The Islamic State claimed responsibility for the attack, saying two attackers — shown in an image put out by ISIS clad in military camouflage and holding Kalashnikovs — had targeted “graduate judges and investigators belonging to the apostate Afghan government.” But a spokesman for the Interior Ministry said on Twitter that “three terrorists” had been killed, ending the hourslong siege.
The Afghan government accused the Taliban of responsibility for the massacre while the Taliban accused the Afghan government of harboring the Islamic State.
None of these statements mitigated the grief over the killings a day earlier.
The National Legal Training Center, built with the support of Italy and the United States, according to a plaque at the entrance, was a ravaged hulk.
Black scarring showed where fire had licked out of the law library’s blown-out windows. Bullet holes were everywhere, including the guard hut where the assailants moved to eliminate what resistance had awaited them. Shrapnel-spattered white boards, discarded shoes, notebooks and a pair of broken glasses remained, as if the Afghan government had already declared the legal center a museum exhibit for the journalists and government officials who wandered the university’s darkened halls Tuesday evening.
How the attack unfolded was still unclear on Tuesday, and the Afghan government has pledged to investigate intelligence failures that may have contributed. But it was evident that gunmen had started on the first floor of the legal center, shooting a guard and teacher next to the front entrance before making their way upstairs, Mr. Naijati said. There the shooters barricaded themselves in a second floor classroom where they were killed hours later by Afghan security forces and a special operations task force that is part of the remaining American-led forces in the country.
Among the dead was Suhaila Yari, 22, one of the 16 students at the university’s school of policy and public administration. Three of the victims, including Ms. Yari, were in the university’s debate club. All of them had excelled on the university entrance exam, just to gain acceptance there.
In her student profile, posted online by one of her professors, she is wearing a bright flowered head scarf, but it was her black one, covering her dark hair, that helped one of her five brothers identify Ms. Yari when a photograph of her lifeless body, her face resting on a red notebook, was posted on social media.
“I can’t express my feelings in words,” her brother, Reza Yari, said. “I don’t know how I felt.”
As he spoke, her burial came to a close in the hills above Kabul, with dusk fast approaching.
“I was with her on Saturday,” he said. “We talked about her university and she said she is getting ready for the exam. But now she is gone. She doesn’t need to be worried about anything.”
Mujib Mashal and Najim Rahim contributed reporting.