ISLAMABAD — It was a Facebook campaign meant to make a stand for free speech. But in Pakistan, a contest encouraging users of the social networking site to submit caricatures of the prophet Muhammad has been viewed as blasphemous, prompting a court-ordered nationwide ban on the website Wednesday.

A court in Lahore, Pakistan’s second-largest city, ordered the government to ensure that the country’s Internet service providers were blocking access to Facebook, the world’s most popular social networking website. In the capital, Islamabad, the site was shut down as of early Wednesday evening.

The ruling was triggered by the campaign, which asked users to post images of Islam’s founder on a page called “Everybody Draw Muhammad Day!”

The campaign was aimed at expressing solidarity with the creators of the Comedy Central television show “South Park,” which recently drew the ire of a radical Muslim group for depicting Muhammad in a bear suit in an episode.

In April, New York-based Revolution Muslim warned “South Park’s” creators, Trey Parker and Matt Stone, on its website that “what they are doing is stupid, and they will probably wind up like Theo Van Gogh.”

Van Gogh was a Dutch filmmaker murdered in 2004 in Amsterdam after he produced a film about the abuse of women in some Islamic societies. In the film, verses from the Quran are projected onto the shrouded bodies of women.

Facebook users were supposed to submit their images today. On Wednesday, a group of lawyers asked the Lahore high court to shut down the site in Pakistan, arguing that the contest amounted to blasphemy. The court ordered Facebook blocked until May 31, when the panel would again take up the case.

Facebook has become immensely popular in the country, which has a vibrant blogging community that sinks its teeth into a variety of topics, including politics, the arts and fashion.