A student who hacked into Facebook in “the most extensive and grave” case of social media hacking ever to come before a British court has been sentenced to eight months in prison.

Glenn Mangham, 26, admitted to infiltrating the website from his bedroom in his parents’ house last year, sparking fears by US authorities that Facebook was the target of industrial espionage. Mangham, a software development student from Cornlands Road, York, claimed that he had previously shown the search engine Yahoo how it could improve its security and said he wanted to do the same for Facebook.

But this was rejected by the prosecutor, Sandip Patel, who told Southwark crown court in London: “He acted with determination and undoubted ingenuity and it was sophisticated, it was calculating. This represents the most extensive and grave incident of social media hacking to be brought before the British courts.” Facebook discovered the breach in May and alerted the FBI, while Scotland Yard’s e-crimes unit raided Mangham’s home on 2 June 2011 following what Patel described as a “concerted, time-consuming and costly investigation”.

Mangham’s claim that he had always intended to alert the website to what he had done was a retrospective justification, rather than his motivation, he added. The student was also given a serious crime prevention order restricting his access to the internet and confiscating his computer equipment.

Facebook said in a statement that it applauded police and prosecutors’ efforts in the case, adding: “We take any attempt to gain unauthorized access to our network very seriously.”