The biggest domestic legal challenge to UK intelligence agencies accessing the mass data harvested by the US National Security Agency (NSA) begins on Monday, and may be one reason behind the government's decision to introduce emergency surveillance laws into parliament next week, campaigners have suggested.

The case is being brought by an alliance of privacy groups in front of the Investigatory Powers Tribunal, a security services oversight body that normally deliberates in private, but will hear legal arguments in public over five days next week. Some of the arguments are likely to cover the legal basis by which the UK intelligence agencies can intercept the data of foreign phone and internet companies. The case has been in preparation since last August, and part of it will revolve on the right of agencies to access material communicated between two people in Britain that is routed through a foreign server.

The emergency data retention and investigatory powers bill, unveiled this week by David Cameron, will impose for the first time a duty on foreign-based internet companies with subsidiaries in the UK to cooperate with surveillance requests by UK agencies. The new laws have also been prompted by the European court of justice in April striking down an EU directive on which the UK security services relied to access data.

The home secretary, Theresa May, will be cross-examined by the home affairs select committee on Monday, with the Commons due to pass the bill in one day on Tuesday and the Lords on Wednesday and Thursday. MPs including Labour's Tom Watson and the Conservatives' David Davis, have raised concerns that the legislation is being brought in too fast to allow proper scrutiny by parliament.

Speaking on LBC radio, Nick Clegg, the deputy prime minister, said the need to put a legal duty on foreign communication service providers stemmed from concerns by the companies about the legal basis on which they are being asked to hand over material to the intelligence agencies.

He said that "a number of communication service providers, big internet companies, many of whom are American, have raised questions about ... the right of the intelligence agencies on our behalf, in exceptional circumstances, on the basis of a warrant signed by a secretary of state, to intercept a telephone call or an email, to actually listen so you can hear the content".

Charles Farr, director general of the Office for Security and Counter Terrorism at the Home Office, has argued in his legal witness statement that general intercepts are permitted under the Regulation of Investigatory Powers Act (Ripa) since they are external. He also argued that a Google search by someone in Britain may be considered an external communication because the request goes abroad to Google's computers, which are based in the US. However, the campaign group Liberty claimed this allows the indiscriminate interception of UK residents' Facebook, Google and other social media communications.

Under Ripa, which regulates the surveillance powers of public bodies, "internal" communications may only be intercepted under a warrant that relates to a specific individual or address. These warrants should only be granted where there is some suspicion of unlawful activity. However, an individual's "external" communications may be intercepted indiscriminately, even where there are no grounds to suspect any wrongdoing.

The government has promised to review Ripa at some point, partly in return for Labour and Liberal Democrat support for the bill. The emergency powers of the legislation also contain a "sunset clause", meaning they expire in 2016, which some fear will be another opportunity for the home secretary to revisit the communications data bill – commonly known as the snoopers' charter.

This legislation, allowing wider retention of data about people's internet usage, was blocked by the Liberal Democrats in 2012 over privacy fears.

Lord Blencathra, the Tory former minister who led scrutiny of the communications data bill, said he did not think the new legislation contained "anything naughty" from the government but he would have liked to see more immediate reform of Ripa and the interception powers of the police and security services.

"I'm not as suspicious as I was when I saw there was emergency legislation," he said. "I don't think they can reintroduce any of the snoopers' charter stuff. However, they are still relying on amending Ripa, and that is no longer fit for purpose. The revised draft bill they were working on had better definitions of communications data, because communications data is almost everything. They are just sticking with the currently flawed Ripa wording. The only trouble is that by amending Ripa like this is giving respectability to Ripa when it is long dead."

Evidence to substantiate the claim that foreign companies are threatening to withdraw cooperation with UK security services amid questions over the legitimacy of Ripa is hard to find. However, in the US courts there is one case of a phone company resisting a National Security Agency (NSA) demand for access to its subscribers' data. In March, the foreign intelligence surveillance court rejected the company's motion and ordered it to continue turning the records over to the NSA. Companies such as AT&T, Verizon and Vodafone are now publishing transparency reports setting out, if permitted by law, the number of law enforcement agency requests for data they receive annually.

More broadly, Congress is enacting legislation to shift the massive phone database out of the NSA's hands, so the NSA would have to obtain a judge's order before going to phone companies for information.

There is a dispute between the phone companies and the NSA about whether the companies could be mandated to keep the records.