(CNN) -- Violence exploded in Iraq over the past 24 hours near Baghdad and in Mosul, leaving nearly 50 people dead and hundreds of al Qaeda-linked militants free in a massive jailbreak, authorities said Monday.
Security forces battled militants outside two major penitentiaries near the Iraqi capital of Baghdad and thwarted prison breaks, the Justice Ministry said Monday. The incidents occurred Sunday night at Abu Ghraib, west of Baghdad, and al-Taji prison, north of the capital.
The Justice Ministry said well-armed "terrorist groups" attacked the prisons simultaneously using mortars. They also carried rocket-propelled grenades and machine guns, and were accompanied by suicide bombers and car bombs, the ministry said.
The attacks coincided with riots by inmates who set fires inside the prisons, the ministry said. At least 21 inmates and at least eight prison guards were killed, it said, while 25 inmates and 14 guards were wounded.
More than 500 inmates escaped from the two jails Sunday night, lawmaker Hakim al-Zamili said Monday. Most were from al Qaeda in Iraq, and some were senior members of the group.
The ministry did not announce the number of escapees, but it said it has formed committees to count the number of inmates in each prison and will announce the number.
Two attacks on Monday rocked Mosul, the northern Iraq metropolis. A suicide bomber blew himself up at an Iraqi army post in the Kokjili district in northern Mosul in the morning, police said. At least 16 people were killed and 21 were wounded. Both civilians and soldiers were among the victims.
Later, at least four people were killed and two were wounded when a roadside bomb exploded near a Sunni mosque in the al-Muthana neighborhood of central Mosul, police said.
The deadly fighting is the latest in a string of violence in recent months, much of it stemming from discord between Sunnis and Shiites. Sunnis have long felt politically marginalized under a Shiite-led government in the post-Saddam Hussein era. They enjoyed more political clout during Hussein's rule, before his ouster after the U.S.-led 2003 invasion.