Andrew Hoyle/CNET

BlackBerry will shut down operations in Pakistan at year's end because demands from the country's Telecommunications Authority would result in a massive invasion of user privacy, the company said Monday.

BlackBerry refuses to agree to the Pakistani government's order to monitor BlackBerry Enterprise Services (BES), including encrypted emails and BBM messages sent and received in the country. It is therefore withdrawing on December 30, Chief Operating Officer Marty Beard said in a blog post Monday. The Canadian company said it enforces a blanket ban on allowing so-called "backdoor" access to customer information anywhere in the world.

"Pakistan's demand was not a question of public safety; we are more than happy to assist law enforcement agencies in investigations of criminal activity," Beard said. "Rather, Pakistan was essentially demanding unfettered access to all of our BES customers' information."

Governments, accustomed to tapping phone lines and opening mail in decades past, want access to people's digital data to help stop crime and security threats. However, especially in the wake of revelations from former NSA contractor Edward Snowden about massive surveillance by the US and UK, tech companies have been wrestling with government data requests that they believe can go too far.

BlackBerry has long emphasized security in its sales pitch to government, military and business customers. On learning that the Pakistani government would require "wholesale" access to BlackBerry Enterprise Services, the company decided its customers' communications would be compromised to the extent that it has no choice but to leave Pakistan altogether.

BlackBerry is setting a precedent for how it will react to being told it must comply or leave, but it is far from the only company facing serious questions. The debate over encrypted communications is raging in many countries, including big markets like the US and UK that are tougher to ignore. If governments come down hard against encryption in the name of national security, tech giants like Google, Apple and Facebook will need to decide on the importance of customer privacy in countries a lot closer to home than Pakistan.