ISLAMABAD, Pakistan — The living were honoring the dead on both sides of the border between Pakistan and Afghanistan on Thursday when militant bombers struck, killing at least 44 people in two attacks that coincided with one of the holiest days on the Muslim calendar.

The heaviest toll was inflicted in the Pakistani city of Quetta, in western Baluchistan Province, where at least 30 people died in a suicide attack at the funeral of a policeman who had been killed just hours earlier.

At the eastern end of the border, in the Afghan province of Nangarhar, a bomb exploded at a graveyard where people had gathered to pay their respects to a slain relative. Fourteen women and children from the same family were killed.

Reporters in Quetta described scenes of chaos and devastation after the attack on the police funeral. At least 21 officers were among the 30 killed, including a deputy chief in charge of field operations, Fayyaz Ahmed Sumbal.

Shahidullah Shahid, a spokesman for the Pakistani Taliban, claimed responsibility for the Quetta attack and said that the group would continue to target police officials, according to local news media outlets.

While the attack underscored Quetta’s fragile security situation, other parts of Pakistan are also turbulent. According to a warning issued Thursday, the State Department has ordered most of its diplomats in Lahore, east of Quetta, to leave in response to a terrorist threat against the American Consulate there.

At this point, it does not appear that the threat against the consulate is related to a broader terror alert that prompted the State Department to close 19 diplomatic missions in the Middle East, Africa and Asia, a senior Obama administration official said.

“The Department of State ordered this drawdown due to specific threats concerning the U.S. Consulate in Lahore,” the warning stated. In dangerous countries, like Pakistan, it is not uncommon for the United States to temporarily close consulates after receiving credible threats.

Except for a small number of emergency personnel, the diplomats in Lahore were moved to Islamabad, the Pakistani capital, the administration official said. The threat against the consulate was first reported by CNN.

Image

Pakistan’s chief justice, Iftikhar Muhammad Chaudhry, second from left, at a funeral for victims of a suicide attack on Thursday in Quetta.CreditBanaras Khan/Agence France-Presse — Getty Images

Thursday’s bloodshed started with the killing of a junior police official, Muhib Ullah. He was shot by unidentified gunmen on his way to a market, and four of his children were wounded. The assailants escaped unharmed.

Hours later, as the city’s police leadership gathered for Mr. Ullah’s funeral in the Police Lines, a relatively secure area that houses police and provincial officials, a suicide bomber slipped through the security cordon and set off his explosives.

The spate of violence has rattled the government of Prime Minister Nawaz Sharif, who ordered Interior Minister Chaudhry Nisar Ali Khan to visit Quetta soon. Mr. Sharif also asked him to present the final draft of a much-awaited national counterterrorism strategy on Aug. 30.

Critics say the lack of such a strategy has resulted in confusion and lack of consensus about how to deal with the terrorists.

Opposition politicians urged the government to immediately convene a national conference of all political parties to come to a policy consensus. “The delay is causing more acts of terrorism,” said Syed Khurshid Shah, an opposition lawmaker belonging to the Pakistan Peoples Party.

The attack in Afghanistan occurred in the Ghanikhel district, near the border with Pakistan. The victims were visiting the grave of a relative on the first day of Id al-Fitr, the Islamic holiday marking the end of the holy month of Ramadan.

Provincial authorities said a bomb apparently planted on a grave exploded once the family gathered around it.

“My family is finished,” Hajji Ghalib, a relative of the victims, told The Associated Press. “These people are inhuman.”

The 14 victims, seven women and seven children, had been visiting the grave of an elder who was assassinated by the Taliban this year. President Hamid Karzai denounced the bombing as “a cowardly act by the enemies of the people of Afghanistan who are not part of any religion.”

A version of this article appears in print on , on Page A7 of the New York edition with the headline: Bomb Attacks Kill Dozens of Mourners in Pakistan and Afghanistan. Order Reprints | Today’s Paper | Subscribe