Nuri al-Maliki told a session of parliament on Wednesday: "They tried but they failed. Nobody can threaten the security of Iraqis. Our forces started to creep into these areas and to control them."
Al-Maliki did not say which group was behind the plan.
Earlier, a suicide bomber walked into a restaurant in eastern Baghdad and blew himself up, killing seven people and wounding 20, police said.
In some of the worst communal violence in Baghdad since the US-led invasion, Shia fighters roamed a mostly Sunni neighbourhood in western Baghdad on Sunday, killing 40 people in a rampage that followed an attack on a Shia mosque there.
Clashes between Sunni and Shia fighters also erupted in western Sunni al-Ghazaliya district over the weekend.