A student who created a website that helped people to watch films and TV shows for free has reached an agreement to avoid extradition to the United States over copyright infringement allegations, the High Court has been told.

Sheffield Hallam University undergraduate Richard O'Dwyer was facing extradition after allegedly earning thousands of pounds through advertising on the TVShack website before it was closed down by the US authorities.

He could have faced jail if convicted of the allegations, which were brought following a crackdown by the US Immigration and Customs Enforcement agency.

Now a judge at London's High Court has been told O'Dwyer has signed a draft agreement in the last two days that involves him travelling to the US and paying compensation, but avoiding a trial and criminal record if found guilty.

Edward Fitzgerald QC, for O'Dwyer, told the court he had agreed to a "deferred prosecution agreement" and intended to honour it. This meant O'Dwyer's pending application to challenge US moves to extradite him were no longer necessary. Sir John Thomas, President of the Queen's Bench Division, said: "It is a very satisfactory outcome."

The court heard that O'Dwyer is expected to travel to the US in the next 14 days to complete the agreement, pay a small sum in compensation and give undertakings not to infringe copyright laws again.

His extradition application is expected to return to the High Court in 15 days' time so it can formally be disposed of. The judge said: "It would be very nice for everyone if this was resolved happily before Christmas."

Home Secretary Theresa May agreed to O'Dwyer's surrender after a court ruled in January that his extradition would be lawful.

Mr O'Dwyer's mother Julia described her "utter relief" at the "fantastic news" of the deal.

Conservative MP and lawyer Dominic Raab, who has campaigned for reform of Britain's extradition arrangements with the US, said: "This is a victory for Richard and his family, a victory for British justice and, above all, a victory for common sense. Now we need to put in law a proper safeguard to prevent these arbitrary cases from happening again. We shouldn't be subjecting British citizens to rough justice under our blunt extradition regime."