On a hot, overcast morning in July, I drove with Yasser Latif Hamdani, a young lawyer with carefully combed-back hair, to Lahore’s grand, decaying, British-era High Court. Hamdani has a growing reputation within Pakistan’s small, liberal-minded “civil society” for his strident advocacy of the claim that the country’s founders envisioned a secular state. (His opinions are published in the English-language newspapers, fringe within a fringe.) On that morning, he was going to court to challenge the Pakistani government’s eleven-month-old ban on YouTube. The site was blocked here in September, 2012, after it declined to take down the trailer for “Innocence of Muslims,” an amateurish film produced in America that maligned the prophet Muhammad and ended up provoking protests last year in many Muslim countries. (Google has said the trailer did not violate its terms of use.)

Hamdani was looking forward to the hearing. “Our efforts would have been wasted if our case had landed before some other judge,” he told me. The judge inspiring his confidence was Mansoor Ali Shah, a rumored liberal who was an advocate of public-interest litigation.

But when, a few hours later, the clean-shaven and bespectacled Justice Shah finally turned his attention to the ban on YouTube, he seemed to lose something of his brisk, authoritative air. In a previous hearing, aided by an amicus curiae, he had identified a solution: a localized version of YouTube, similar to versions of the site in many other countries, but in which videos flagged as being offensive to religious / cultural / national sensitivities could be removed or restricted by Google. But Google, the parent company of YouTube, had declined to send its representatives to the hearing. In a letter sent to the Pakistani government and presented in court, Google pointed out that it was not subject to the High Court’s jurisdiction. (The company declined to comment further.) This left the judge with two choices: either to accept the government’s argument, woven in calm bureaucratic sentences by officials from the Pakistan Telecommunications Authority and the Ministry of Information Technology—that they had neither the expertise nor the manpower to isolate blasphemous videos on the Web, necessitating a total ban of YouTube—or to side with Hamdani and his client, an N.G.O. called Bytes for All, which accused the government of violating Pakistani citizens’ constitutional right to freedom of expression and right to information.

At one point, a stout, middle-aged official from the P.T.A. informed the judge that Part Two of “Innocence of Muslims” was about to be released. The man, looking grave, said that government was bracing itself for the reaction that was guaranteed to break out on the streets. Justice Shah, who had been massaging his mouth in exasperation, turned to a red-faced Hamdani and said, “My problem is it could lead to a law-and-order situation again …. We have to accept there are those elements in our country …”

The “law-and-order situation” of last September can seem, when one is looking at headlines from that time, like a spontaneous emotional eruption—a countrywide surge of anger that shot up in response to “Innocence of Muslims.” But, as in Libya, where investigations into the film’s supposed role in inspiring an attack on an American diplomatic installation in Benghazi have shown, the reality is more complicated, and it is mixed up with local politics.

That September, Islamist groups, including some madrassas and a few political parties, taking their cue from protests in other Muslim countries, came out against the film and made it into a larger, anti-American—and, by extension, anti-ruling-party—affair. Protestors marched to the U.S. Consulate in Karachi, pelted it with stones, and were teargassed by police; protestors responded by setting fire to vehicles. Their agitation was broadcast by the national media, complemented by cries of indignation from right-wing columnists and TV commentators.

Then the Supreme Court joined the fray: after a lawyer raised the issue of blasphemy, the activist Chief Justice, Iftikhar Muhammad Chaudhry, who had recently taken notice of obscenity and vulgarity on the Internet, summoned the chairman of the P.T.A. and told him to block access to all sacrilegious material at once. The government blocked YouTube and announced a national holiday with the florid name Youm-e-Ishq-e-Rasool (A Day for the Love of the Holy Prophet).

I walked through the avenues of Lahore’s old commercial district on Youm-e-Ishq-e-Rasool, where I thought I might catch the tides of public passion. But instead I found a state-sponsored expo: most of Pakistan’s political parties (including the Pakistan Peoples Party, then in power) were out with flags and slogans, trying to score more ideological points than their rivals. (“Slaves of America!” was the charge flying back and forth between the various camps.) Distinct from these party-liners were cadres of Islamist organizations, marked by their flags—usually depicting a sword or two—and more explicit slogans (“Death to America!” “Jihad till the End!”). Some of these men had kaffiyehs around their faces and were hurling rocks at the giant freight containers blocking the way to the U.S. Consulate. The louder the containers clanged, the faster the policemen standing on top of them threw tear-gas shells at the crowd.

The rest was carnival: I saw bands of smiling schoolchildren with sticks in their hands, met members of neighborhood associations with colorful placards, and talked to poor children wearing black-paper hats that said “MUHAMMAD” in large white letters, who had been piled into buses, lured to the protest on the promise of free biryani lunches. Walking in proud processions were carriers of homemade effigies, and behind them were people walking dogs with bibs that said “Barack Obama” and “Hillary Clinton.” Some men sold sugarcane juice under a tree with speakers wedged into its branches, blaring ecstatic religious music, while others sold badges—“Badges! Lovely, lovely badges!”—with messages like “Sever the Heads of Blasphemers.” Beggars and men in wheelchairs trailed after hawkers and sightseers, repeating the slogans as they asked for money.

That was a year ago. The commotion has long since died down; an election has recently brought a new government to power. But YouTube is still blocked in Pakistan.

Google has diverse presences in other Web-censoring countries. In China and Iran, where censorship is the norm, YouTube is completely blocked, but in Saudi Arabia a state agency filters pornographic and other “immoral” sites. From 2007 to 2010, YouTube was repeatedly blocked in Turkey for posting videos that “insulted Turkishness” and the country’s founder, Kemal Ataturk. Eventually, a company in Germany asserted a copyright to those videos and took them down, and YouTube was unbanned. Google blocked the trailer for “Innocence of Muslims” in Indonesia, India, Jordan, Malaysia, Russia, Singapore, and Turkey after the governments of those countries requested removal of the video from YouTube. So the censorship that the site has accommodated, in various ways and to various extents, does not pose a dilemma for YouTube, per se. But it leaves possible security issues for any in-country staff, along with potential legal liabilities. Google would need exemption from country-specific laws in the window of time that exists between a potentially offensive video being uploaded and it being removed or restricted on the site. But, as Google stated in its letter to the Lahore High Court, it hasn’t been offered that protection in Pakistan. (The letter says that Google requires more than just an expression of goodwill from the Lahore High Court; it needs a “legislative change” in Pakistan that insures Intermediary Liability Protection for Web forums in general.)

But the fazaa (the political atmosphere or temperature) in Pakistan doesn’t at present allow for such settlements. At least some of this resistance comes directly from the Pakistani state, according to Basit Riaz Sheikh, who has a Ph.D. in electrical engineering and was advising the government when YouTube was banned. Sheikh said that he had spent hours trying to reason with the Inter-Ministerial Committee for the Evaluation of Web Sites, a body dominated by men from the Ministry of Religious Affairs, the Inter-Services Intelligence (I.S.I.), and Military Intelligence: the ban hadn’t brought an end to anti-Islamic propaganda on the Internet, nor had it stopped Pakistanis with personal computers from using YouTube. Just days after the ban was imposed, people with downloaded V.P.N. software accessed YouTube from all over the country. The ban, Sheikh argued, was only hurting Pakistan’s students, musicians, and entrepreneurs, who relied on YouTube for work and were suffering because of the decline in Internet traffic.