The website was blocked Sunday by the telecoms authority on the orders of the IT ministry amid accusations it refused to remove messages about the Facebook contest. But the Pakistan Telecommunication Authority (PTA) restored access to Twitter in the evening, several hours after it was cut off, said spokesman Mohammad Younis Khan.
The reason for the U-turn was not immediately clear. Khan said it was the IT ministry's decision and he did not know why it had been taken, and no one from the ministry or Twitter was available for comment.
Speaking before the ban was lifted Sunday, Khan said that there was "blasphemous material" on Twitter and that the organisers of the competition had been "trying to hurt Muslim feelings". Islam bans images of the Prophet.
"Both Facebook and Twitter were involved. We negotiated with both. Facebook has agreed to remove the stuff but Twitter is not responding to us," he said. Facebook confirmed that it had blocked content in Pakistan after a request from the authorities.
"Out of respect for local laws, traditions and cultures, we may occasionally restrict (some content's) visibility in the countries where it is illegal, as we have done in this case," said a spokeswoman.
Twitter told AFP that it did not remove any content or make any changes at the service to get it restored but declined to comment further.
Twitter received a FAX message on Saturday from a minister in Pakistan saying that material deemed objectionable was at the website and the service would be suspended if action wasn't taken, according to a source close to the situation.
Twitter policy is to comply with local laws regarding content at the service but the FAX message was not a court order, according to the source, who noted that Twitter was not told what prompted the decision to restore the service.
The ban had sparked anger, and many in Pakistan appeared to have found a way to circumvent the restrictions and post on the microblog regardless.
Ali Dayan Hasan, Pakistan director at Human Rights Watch, said the ban was "ill-advised, counter-productive and will ultimately prove to be futile as all such attempts at censorship have proved to be".
Philip Crowley, who last year resigned as US State Department spokesman, wrote on the microblogging site: "Pakistan's decision to block Twitter is another sign of the civilian government's weakness."
In Pakistan, Twitter is used by prominent public figures such as celebrities, cricketers, cabinet ministers and members of parliament. Former president Pervez Musharraf, in exile in Britain, regularly tweets, as does Ali Zafar, the popular actor and musician. Imran Khan, the cricketer turned politician, is also on Twitter.
Pakistan blocked Facebook in May 2010 because of a competition organised by an anonymous user who called on people to draw the Prophet to promote "freedom of expression".
The competition sparked a major backlash in conservative Muslim Pakistan, where even moderates were deeply offended by the drawings that appeared on the "Everyone Draw Mohammed Day" Facebook page.
It saw Facebook blocked for almost two weeks after a petition by a group of Islamic lawyers. The PTA also banned YouTube for a week and restricted access to other websites, including Wikipedia, lashing out against "growing sacrilegious" content.
Muslims across the globe staged angry protests over the publication of satirical cartoons of Mohammed in European newspapers four years ago. A suicide attack outside the Danish embassy in Islamabad that year killed eight people. Al-Qaeda claimed the attack to avenge the cartoons.