ISLAMABAD, Pakistan — The Pakistani government blocked access to the social networking service Twitter for much of Sunday, after publicly holding Twitter responsible for promoting what it described as a blasphemous cartoon contest taking place on Facebook, officials said.

The restoration of Twitter service late in the evening was as sudden as its suspension earlier in the day. No official statement or explanation was given for an act that some rights campaigners saw as much as a warning shot at the media and public expression as a reaction to controversial content.

The shutdowns began around midday Sunday, in a rolling ban that almost immediately brought a huge public outcry on other social media.

A government spokesman was quoted by local news media early on Sunday as saying that the government had been in talks with Twitter to remove “objectionable” material, but that there had been no results. “The material was promoting a competition on Facebook to post images of Islam’s Prophet Muhammad,” Mohammad Yaseen, chairman of the Pakistan Telecommunication Authority, told Pakistani news organizations. He was also quoted as saying that Facebook had agreed to allay the concerns of the Pakistani government.