BAGHDAD — Dozens of Sunni worshipers were killed during a militant raid on a rural mosque in central Iraq on Friday, an attack that security officials said had followed the attempted assassination of a local Shiite leader.

It was not immediately clear who carried out either attack or whether they were even linked, but the violence still stoked sectarian recriminations and threatened to complicate efforts by Iraq’s newly designated prime minister, Haider al-Abadi, to form a government to run the country.

Iraq has been struggling with a new wave of violence and political turmoil since extremists from the Islamic State in Iraq and Syria seized territory in the country’s north and west, including its second-largest city, Mosul.

The United States has called the formation of an inclusive government a key step toward dealing with ISIS and suggested that it could lead to greater American aid to the Iraqi government and its armed forces.