Baghdad (AFP) - Attacks killed at least 46 people in Iraq on Saturday, including a suicide bombing claimed by the Islamic State group that was the deadliest to hit Baghdad in months.

The violence comes as Iraqi forces prepare for an operation to retake Mosul, the last IS-held city in the country -- a key battle, but one that will not end the threat of attacks such as those carried out on Saturday.

In the deadliest attack, a suicide bomber targeted a funeral tent where mourners were gathered to pay their respects in the Shiite-majority Shaab area of north Baghdad, killing at least 34 people and wounding least 36, officials said.

IS issued an online statement claiming the attack, saying it was carried out by a man who detonated an explosive vest.

A witness said the bomber entered the funeral tent and blew himself up as lunch was being served.

"I saw with my eyes 20 martyrs on the ground," the witness said.

Blood stained the ground at the scene of the attack, which was littered with the remains of plastics chairs mourners had been seated on.

IS, a Sunni extremist group, considers Shiites to be heretics, and frequently carries out suicide bombings and other attacks against them in Baghdad and elsewhere in the country.

Saturday's bombing is the deadliest to hit the Iraqi capital since early July, when a suicide bombing in central Baghdad sparked infernos in a crowded shopping area, killing more than 300 people.

That attack led to a shakeup of senior Baghdad security officials and the announcement of other measures aimed at improving security in the capital, but the bombings have continued.

Also on Saturday, militants attacked two areas north of Baghdad, killing a further 12 people, according to police.

- Series of Baghdad blasts -

In Malha, an area east of the city of Tikrit, suicide bombers attacked a federal police position, killing eight and wounding 11, officers said.

And in the Ishaqi area, two militants shot dead the wife and three children of the commander of local tribal forces before fleeing and blowing themselves up when they were cornered by Iraqi forces.

There was no immediate claim of responsibility for those two attacks, but Saturday's Baghdad bombing was just the latest in a series that IS has said it carried out against Shiites in the capital.

One IS-claimed bombing in Baghdad on October 9 killed at least five people, while two more earlier in the month left a total of at least 10 dead, and two others killed at least 17 people at the end of September.

The attacks come as Iraqi forces prepare for an offensive in northern Iraq to retake Mosul, the last IS-held city in the country, after regaining much of the territory the jihadists seized in 2014 and 2015.

The launch of the operation is expected to be announced soon, but it will mark only the start of a battle that is likely to be the most difficult and complex yet in the war against IS.

A coalition of heterogenous and sometimes rival Iraqi forces will have to fight their way through IS defences to reach the city, in some cases over distances of dozens of kilometres (miles).

Then they will likely seek to surround the city before launching an assault, marking the start of deadly street fighting with die-hard jihadists in a city with a large civilian population.

The battle may spark a humanitarian crisis, with the United Nations warning that up to one million people may be displaced by the fighting as winter sets in.

Even the recapture of Mosul will not mark the end of the war against IS, which still holds other territory in Iraq and is likely to turn increasingly to insurgent tactics such as bombings and hit-and-run attacks as it loses more ground.