Police have defended launching an operation in which they "spied" on Cambridge University students in order to prevent another Lee Rigby-style murder occurring in the city.

Cambridgeshire Police launched a secret operation to track political activities of students who studied at the university.

The force said the tactics involved were all legally sound and necessary "to assist in the prevention and detection of criminal activity", the Guardian reported.

As part of the operation, an officer attempted to persuade an activist at the university to become an informant and give him information about other students and their protests in exchange for money. The plan was exposed after the activist recorded meetings with the officer.

Cambridge University Students' Union (CUSU) said it was "absurd" that its members were targeted by police in this way.

Cambridgeshire's police commissioner, Sir Graham Bright, has defended the actions of the force and he said he did not want the sort of crime to happen in Cambridge "like it did in Woolwich".

Bright was referring to the murder of Fusilier Rigby, who was hacked to death as he made his way to his barracks in south London on 22 May.

Cambridge MP Julian Huppert asked Bright about the bungled operation during a meeting of the House of Commons Home Affairs Select Committee.

Bright said he spoke to Chief Constable Simon Parr, who assured him that the police action was legal. Bright also explained his reasons for carrying on with the surveillance.

He said: "Well it was obvious why it was being done. Were we within the rules? There was a 2000 act which spelt out quite clearly what the rules were and our police service is monitored and inspected by the appropriate authority and certainly there is no reason to believe they acted outside the remit that they had.

"You and I know that there is always that sort of activity taking place. One dreads to think that something could happen in Cambridge like it did in Woolwich.

"And you know it has to go on. But the thing is to ensure it is done in the right way and sticks to the rules and as I say the rules are there quite clearly for everyone to read."

Felicity Osborn, president of CUSU, described the comparison to the Woolwich mudrer as "distasteful and unfortunate".

She added: "The student surveillance at hand here is absurd. We affirm students' right to protest peacefully and as such to participate in the democratic process.

"CUSU will consider to work with the police constructively and we are hopeful that Sir Graham will reconsider his response to our invitation."

Julian Huppert, Liberal Democrat MP for Cambridgeshire, tweeted it is "simply astonishing" that Bright made a link with the CUSU's activities to the "atrocities" which occurred in Woolwich.

The two men accused of murdering Rigby, Michael Adebolajo, 28, and Michael Adebowale, 22, are due to stand trial at the Old Bailey.