It said in a statement that the operation was conducted in coordination with the security forces and the judiciary.
It "resulted in the dismantling of terrorist groups linked to what is known as Wilayat Baghdad (Baghdad province), a part of the terrorist group Daesh," the statement said, using an Arabic acronym for IS.
The intelligence service said the 31 people arrested are IS members from all parts of Baghdad, as well as areas south and north of the capital.
It said "large quantities of arms, (explosive) belts, silencers, rigged cars and motorcycles, statements, videos of their cowardly operations" were seized.
More From This Section
The statement does not say exactly when the arrests were made but the spokesman for the intelligence service suggested they were last month.
"The reason for the decrease in attacks in Baghdad over the past three weeks is the arrest of this network," Fahim al-Atraqchi told AFP.
The number of attacks in Baghdad, which at one point last year used to be rocked by car bombs almost every day, has dropped this year.
Early this year, they took back all of Diyala province, which lies to the northeast, allowing Baghdad to breathe more comfortably.
The years-old nightly curfew on Baghdad was lifted last month.