After the last prayer of the Thursday morning memorial service for President Hamid Karzai’s slain half brother, a senior cleric inside the city’s Red Mosque announced that lunch would soon be served.

For the distinguished guests clustered on the side of the vast carpeted prayer hall — including the governor of Kandahar province and four of Karzai’s brothers — a meal was ready across town at the Mandigak palace, where the provincial council meets, the cleric said.

The others could eat in the mosque, served by the boys scattered across the room.

As the guests stood to leave for lunch, a bomb hidden inside a man’s turban detonated, killing at least four people and wounding 15, according to Afghan officials and witnesses.

The attack defied stringent security measures put in place after Ahmed Wali Karzai was fatally shot at his home by a longtime confidant Tuesday. The attack during the high-profile memorial service illustrated again the vulnerability of Afghan officials as the United States works to transfer security responsibilities to the Afghans, and it demonstrated the intensity of the campaign to take out government loyalists.

None of the Karzai family members died in the blast Thursday.

“It was a very, very, very close call,” said Mahmoud Karzai, one of the Karzai brothers, who said he was about 20 feet from the bomber. “The guy didn’t recognize us. It was a miracle we got out of there alive. . . . This could have been a major disaster for my family.”

Other witnesses said there was a somewhat greater distance between the bomber and the area where the Karzai family and other high-level dignitaries were seated — perhaps 40 yards.

When the bomb went off, “everyone was quiet for a second,” said Gul Mohammad, 40, a driver who attended the service. “Then everyone panicked.”

Guests quickly formed a circle around the Karzai family members and hustled them from the mosque unharmed, witnesses said, while the dead and injured lay bleeding and burned in the smoky room.

Among the dead was the chief cleric of Kandahar, Maulvi Hekmatullah Hekmat, officials said. All of the cabinet ministers and senior officials who had traveled from Kabul for the event survived.

Mahmoud Karzai blamed the attack on Pakistan, where many Taliban leaders reside. “How long are we going to pretend, Afghans and Americans? Why is there so much patience with Pakistan? Are they so powerful?” 

In an unusual public airing of family disagreements, he criticized President Karzai, his brother, for his willingness to negotiate with the Taliban. “The policy is incorrect. They’re hitting us and my brother’s saying, ‘We want peace.’ We’re under siege,” Mahmoud Karzai said. “For him to say we want peace is very easy; he’s not threatened by this violence.”

President Karzai, who attended his half brother’s funeral Wednesday but was not at the memorial service, said the bombing “was entirely an act contrary to Islam and humanity” and had “no justification in any religion or sect.”

Meanwhile, a report released Thursday by the United Nations highlighted the Taliban’s reach in carrying out attacks. It showed that civilian deaths in Afghanistan increased by 15 percent in the first six months of 2011 over the same period last year, even as attacks on NATO and Afghan forces began to decline.

The bulk of the 1,462 deaths from January to June were caused by roadside bombs planted by the Taliban, according to the U.N. report. The past two months were the deadliest for civilians since the organization began keeping count in 2007.

“Afghan children, women and men continue to be killed at an alarming rate,” said Staffan de Mistura, special representative of the U.N. secretary general.

Gen. David H. Petraeus, the top U.S. military commander in Afghanistan, said last week that the number of insurgent attacks on NATO and Afghan forces declined in the past two months by “a few percent,” compared with the same months last year.  

The increasingly deadly roadside bombs “are meant to hit tanks, but they’re triggered mostly by minibuses, cars or civilians walking,” de Mistura said Thursday.

In its report, U.N. officials recognized recent NATO efforts to avoid civilian casualties, pointing to the decrease in the total number of civilians killed by the coalition. At the same time, the number killed specifically by NATO airstrikes, which are hugely controversial in Afghanistan, increased by 14 percent.

The report placed most blame for civilian casualties on the Taliban, which it said was responsible for about 80 percent of the civilian deaths. 

“More than a report, this is an appeal,” de Mistura said. He said the report’s authors had contacted Taliban representatives, who disputed the U.N. findings.

Special correspondents Sayed Salahuddin in Kabul and Javed Hamdard in Kandahar contributed to this report.