DUBAI—The Iraqi government is blocking news and social-media websites in some areas and shut down the Internet entirely in others in a bid to keep extremist Sunnis from building public support through online channels.

The moves follow those of some governments in the Middle East. Facebook and Twitter helped amplify the grievances that led to the Arab Spring, which toppled three regimes, and served as critical organizing tools.

The...