TVShack founder avoids prosecution under copyright laws and says: 'It is a pity the UK government didn't try and resolve this'

A British student's two-year fight to avoid extradition to the US ended in less than five minutes on Thursday, when Richard O'Dwyer signed an agreement in a New York court to avoid prosecution and a potential 10-year jail term for breaking copyright laws with the file-sharing website he set up as a teenager.

The 24-year-old spoke only to confirm his name and his understanding of the three-page agreement, which was reached last week by his legal team and US prosecutors.

The brief hearing in lower Manhattan marked the end of an ordeal that dates back to October 2010, when O'Dwyer was arrested by City of London police, accompanied by US customs officials, in his student room in Sheffield.

Outside court, O'Dwyer and his family criticised the British government's response to the case, saying they had received little support from the Home Office. Theresa May, the home secretary, approved O'Dwyer's extradition to the US despite opposition from the public, press and some politicians.

"I'm very happy it's finally over with," O'Dwyer told the Guardian (video), outside the court in lower Manhattan. "I still believe I never committed any crime. I'm very happy the US government has decided to drop the case against me. It just really is a pity the UK government didn't try and resolve this without us having to come all the way over."

The hearing, in New York's southern district court, lasted only a few minutes. O'Dwyer, wearing a blue hooded top and denim jeans, with union-jack boxer shorts visible above the waistband, signed the document as his mother, Julia O'Dwyer, looked on from the back of the small courtroom.

Under the terms of the "deferred prosecution agreement", which was agreed last week, the student pledged that he would not break any laws and would remain in contact with a US correctional officer over the next six months.

He was also ordered to pay the US dollar equivalent of £20,000, which represents profits earned by his website between December 2007 and November 2010. The money will be used to "repay victims whose copyrights were infringed by TVShack", according to the agreement.

O'Dwyer set up TVShack, which linked to programmes and films available for free online, in 2007. He was arrested on allegations of copyright infringement three years later, but a criminal investigation in the UK was dropped. The US Immigration and Customs Enforcement Agency shut down the website and accused O'Dwyer of breaking US copyright laws, prompting his two-year fight to avoid extradition.

Julia O'Dwyer, who campaigned hard on her son's behalf, told the Guardian outside court that she had been frustrated by the British government's handling of the case.

She said: "We're really pleased to have been here and to sort this matter out without needing for Richard to be subjected to extradition and incarceration and criminalisation. It's just a pity that the British authorities couldn't have allowed us to sort this out in the UK."

She praised supporters of her son, but was critical of the British authorities. "That doesn't feel very nice that your own government gives you no support. We've had tremendous support from the public, from the press, from our legal team, other victims. But the Home Office, the CPS [Crown Prosecution Service], the politicians – no support at all."

The case has had a high profile in Britain. The Wikipedia founder, Jimmy Wales, launched a campaign in June, with an article in the Guardian in defence of O'Dwyer. Wales described the student as the "human face" of a global battle between film and TV industries and the wider public.

More than 253,000 people signed a petition set up by Wales which called upon the home secretary to block O'Dwyer's extradition to the US. May insisted she would not back down on her approval of the extradition. The decision proved highly unpopular among the British public – a YouGov poll found that 46% of respondents believed O'Dwyer should not be prosecuted at all, and that only 9% thought he should be sent to the US for trial.

Ben Cooper, O'Dwyer's barrister who accompanied him to New York and negotiated the deal with US prosecutors, said: "Richard O'Dwyer is very happy to put this behind him. He has avoided extradition and will avoid a conviction.

"The solution reached is pragmatic and allows Richard to finish his final year at university and get on with his studies at a crucial time in his life.

"We are grateful that the US recognised the disproportionality of extradition and was prepared to find a practical solution."