Supporters of media reform have failed in their attempt to force the government to hold the second part of the Leveson inquiry into the actions of the press, potentially bringing the long-running investigation to an end after seven years.

Four victims of press intrusion had argued that the government did not have the right to cancel the inquiry into the relationship between newspapers and the police. But a court ruled that ministers had met their legal obligations when they decided not to press ahead with the inquiry.

The first part of the investigation was launched in the wake of the 2011 phone-hacking scandal and looked at the conduct and ethics of the press. It made a number of recommendations, many of which were ignored, about the future of newspaper regulation in the UK. Its report led to the formation of several new press regulators but the inquiry has since been criticised for largely ignoring the role of the internet.

The second part was delayed pending the outcome of several criminal trials, but in March the then culture secretary, Matt Hancock, told parliament that it would be cancelled as it was “costly and time-consuming” and not “the right way forward”. He argued that justice had been served through a number of criminal trials which had put dozens behind bars.

Four individuals brought the legal challenge to this decision, with the support of the campaign group Hacked Off. The four were phone-hacking victim and former Crimewatch presenter Jacqui Hames, the Bristol schoolteacher Christopher Jefferies, who was wrongly accused of murder, and Gerry and Kate McCann – the parents of missing child Madeleine McCann.

At a hearing earlier this month, the four argued that in November 2012 the former prime minister David Cameron made a “clear and unambiguous commitment” that the second part of the inquiry would go ahead. Their lawyers said that commitment, made at a meeting with Jefferies, Mrs McCann and Hames, meant they had a “legitimate expectation” it would proceed.

But Lord Justice Davis said Cameron made “no such promise” in the meeting and that it was unacceptable that the case was based on a covert recording of the discussion, despite participants having agreed that what was said in the meeting would remain confidential.

The judge said he had a great deal of sympathy for the claimants but that sympathy could not override the law and the legal case failed “at almost every level”.

A spokesperson for Hacked Off said that while the court concluded that the government had acted legally cancelling the second part of the inquiry, the decision had “let some press executives off the hook after years of illegality and press abuse which occurred in their organisations while they were in post”.

“Hacked Off will continue to explore all avenues to ensure the inquiry takes place as promised,” they added.

Earlier this year, parliament narrowly voted against setting up a new inquiry into the activities of the media which would have covered much of the same ground as part two of the Leveson inquiry, while also expanding its remit to look at the activities of social media companies.

Separately on Thursday, the press regulator Impress announced that it had secured funding that would sustain it until at least 2022, thanks to the offer of a £2.85m donation from a charitable trust ultimately funded by Max Mosley.

Impress is the only officially recognised regulator under the changes put in place by the Leveson inquiry but largely regulates tiny online publications and only dealt with 162 complaints from the public during the last year. Most major British newspapers instead chose to be regulated by rival outfit Ipso. The Guardian, in common with the Financial Times, follows a process of self-regulation through a readers’ editor.

Almost all of Impress’s funding has come indirectly from a charitable trust founded by former motor sport boss Mosley, who successfully sued the News of the World for invading his privacy with a front-page story about his sexual activities and has since campaigned for press regulation.

Earlier this year Labour said it would not accept any more donations from Mosley, following accusations that he published a racist leaflet in the 1960s linking immigrants with disease while campaigning for his father’s far-right Union Movement political party.