Police funding cuts have been partly blamed for the collapse of a rape trial amid fears over potential miscarriages of justice.

A judge threw out the charges against 22-year-old Liam Allan after lawyers discovered messages showing the claimant wanted and enjoyed the sex she later claimed was non-consensual.

Mr Allan had been on bail for almost two years by the time the discovery was made, three days into his trial at Croydon Crown Court.

The messages had been obtained by police when they downloaded the contents of the woman’s phone, but investigators later told the lawyers they contained nothing relevant.

The Crown Prosecution Service (CPS) has announced a review into the case, while the Metropolitan Police said it was “urgently” examining what happened.

Julia Smart, a barrister who defended Mr Allan, said she did not find out the content of the complainant’s phone had been downloaded until a week before the trial.

An initial request to see the contents was declined but a judge granted a formal application on the first day of the trial.

“I took the disk away to discover there were 40,000 messages on it,” Ms Smart told The Independent.

“I read them through the night and into the next morning. It was laborious but I found messages that completely undermined the case.”

The Metropolitan Police and Crown Prosecution Service are investigating the case (Getty)

Mr Allan was charged with six counts of rape and six of sexual assault after the woman reported him to police, claiming their relationship was unhappy and abusive, and she did not want sex.

“These messages said quite the contrary – that she was extremely happy for the defendant to come back to her after they broke up and extremely happy with the sex,” Ms Smart said.

The defence argued that the sex was consensual and told jurors the woman was attempting to frame Mr Allan, a criminology student at Greenwich University, because he ended their relationship.

Mr Allan said he was “still wrapping my head around” the ordeal when contacted by The Independent and is considering seeking compensation from police.

The claimant could also be prosecuted for perverting the course of justice for allegedly making a false rape allegation.

Acquitting Mr Allan of all charges, judge Peter Gower said the CPS should be considering the matter at the “very highest level”.

“Something has gone very, very wrong in the way this case was investigated and brought to court,” he said, according to The Times.

“There is a risk not only of this happening again, but that the trial process will not detect what has gone wrong and there will be a very serious miscarriage of justice.”

Jerry Hayes, the prosecuting barrister, apologised to Mr Allan and presented no evidence against him on the day the trial collapsed.

“It was the right thing to do,” he later wrote on Twitter. “[The messages] were not disclosed to anybody – not in unused, not sent to the CPS, not on caselines.”

Ms Smart said it appears the Scotland Yard officer who had the phone record “probably didn’t look at it” in full.

UK news in pictures Show all 50 1 /50 UK news in pictures UK news in pictures 18 September 2020 A model presents a creation during the Bora Aksu catwalk show at London Fashion Week 2020 Reuters UK news in pictures 17 September 2020 World kickboxing champion Carl Thomas during his attempt to run a marathon while pulling a plane at Elvington Airfield near York. The attempt is raising funds for Ollie's Army Battling Against Battens, an organisation campaigning to raise GBP 250,000 to fund a clinical trial aimed at saving the sight of children with CNL2 Batten Disease PA UK news in pictures 16 September 2020 Labour deputy leader Angela Rayner speaking during Prime Minister's Questions UK Parliament/AFP/Getty UK news in pictures 15 September 2020 People enjoying the autumn sunshine as they punt along the River Cam in Cambridge PA UK news in pictures 14 September 2020 Early morning light bathes the skyscrapers of the City of London, at the start of a week in which the UK is expected to bask in temperatures of more than 30 degrees PA UK news in pictures 13 September 2020 England celebrate after they dismissed Australia's Alex Carey to win the second ODI match of the series at Emirates Old Trafford, Manchester PA UK news in pictures 12 September 2020 Protesters outside BBC Broadcasting House in central London, as marches and rallies form across the country calling for a 15% pay rise for NHS workers and an increase in NHS funding PA UK news in pictures 11 September 2020 An empty migrant dinghy floats off the beach at St Margaret's Bay after the occupants landed from France in Dover Getty UK news in pictures 10 September 2020 A view of small boats thought to be used in migrant crossings across the Channel at a storage facility in Dover, Kent PA UK news in pictures 9 September 2020 EU's chief negotiator Michel Barnier, left, arriving from the Eurostar with EU Ambassador to the UK, Portuguese diplomat Joao Vale de Almeida at St Pancras International railway station, London, for the latest round of the negotiations on a free trade deal between the EU and the UK PA UK news in pictures 8 September 2020 Dawn over Coquet Island, a small island off Amble on the Northumberland coast PA UK news in pictures 7 September 2020 A hovercraft arrives to Southsea, Hampshire from the Isle of Wight PA UK news in pictures 6 September 2020 Forensics officers near the scene of multiple reported stabbings in Birmingham Reuters UK news in pictures 5 September 2020 Anti-migrant protesters demonstrate in Dover against immigration and the journeys made by refugees crossing the Channel to Kent PA UK news in pictures 4 September 2020 Activists take part in a demonstration against the HS2 hi-speed rail line outside the Department of Transport AFP via Getty UK news in pictures 3 September 2020 Peter Baker, who plays Trigger in the musical version of Only Fools and Horses, sweeps the stage of the Theatre Royal Haymarket in London, after observing a 15 minute silence to show solidarity with those in the theatre industry that have lost their jobs due to the coronavirus pandemic PA UK news in pictures 2 September 2020 Kadie Lane, right, 11, and Brooke Howourth, 11, hug on their walk to Marden Bridge Middle School in Whitley Bay, Tyne and Wear, for their first day of term, as schools in England reopen to pupils following the coronavirus lockdown PA UK news in pictures 1 September 2020 Extinction Rebellion protesters sitting outside The Houses of Parliament in Westminster, London PA UK news in pictures 31 August Surfers at Long Sands Beach, Tynemouth PA UK news in pictures 30 August Black Lives Matter protesters march through Notting Hill in London in the first Million People March EPA UK news in pictures 29 August A protester reacts as she demonstrates against the lockdown and use of face masks, amid the coronavirus disease outbreak, outside Downing Street in London Reuters UK news in pictures 28 August Caribbean soca dancers display their costumes as they promote the first ever digital Notting Hill Carnival, following the cancellation of the normal Carnival festivities due to the continued spread of the coronavirus disease, in London Reuters UK news in pictures 27 August Father and son team Chris and Sam Milford from historic building conservation specialists WallWalkers begin restoration work on the spire of Norwich Cathedral, which stands at over 312ft high. The first known spire was completed in 1297 PA UK news in pictures 26 August Giant waves at Seaham in County Durham, as the bad weather continues PA UK news in pictures 25 August An assistant at the Wallace Monument cleans the case which houses the William Wallace sword in the Hall of Arms room at the monument near Stirling as they prepare to re-open PA UK news in pictures 24 August Restored World War Two landing craft LCT 7074 is transported from from the Naval Base in Portsmouth to its final resting place at the D-Day Story at Southsea PA UK news in pictures 23 August Jenny Nguyen and Tony Cao, from Vietnam, pose for wedding photos on Tower Bridge in London, as it remains closed to vehicles after it was stuck open on Saturday due to a "mechanical fault". The landmark's Twitter account confirmed only pedestrians and cyclists could use it on Sunday morning PA UK news in pictures 22 August England's Zak Crawley hit 267, joining the exclusive Double Hundred club, on day two of the Third Test match against Pakistan at the Ageas Bowl, Southampton PA UK news in pictures 21 August Harri Teale gathers lavender during the annual harvest on the Wolds Way Lavender farm near Malton in North Yorkshire PA UK news in pictures 20 August Parents and a student react after checking GCSE results at Ark Academy in London Reuters UK news in pictures 19 August Tate Modern workers hold a strike outside the gallery in London, to protest the institution's announcement that it would cut more than 300 jobs from its commercial arm, Tate Enterprises PA UK news in pictures 18 August Two rescued brown bear cubs, Mish (left) and Lucy, cool off in a pool after arriving at their new home with the wildlife conservation charity Wildwood Trust in Herne Bay, Kent. The orphaned pair, who have been living in a temporary home in Belgium since they were found abandoned and alone in a snowdrift in the Albanian mountains, will be acclimatised to their new life in the country before moving to a permanent home PA UK news in pictures 17 August A level students celebrate outside the Department for Education in London after it was confirmed that candidates in England will be given grades estimated by their teachers, rather than by an algorithm. The government U-turn comes just days after Education Secretary Gavin Williamson vowed there would be "no U-turn, no change. PA UK news in pictures 16 August Wasp players take a knee as Northampton Saints stand prior to kick-off in their Premiership match at Franklin's Gardens PA UK news in pictures 15 August Piper Colour Sergeant Lil Bahadur Gurung attends the VJ Day National Remembrance event, held at the National Memorial Arboretum in Staffordshire, Britain Reuters UK news in pictures 14 August People including students hold placards on Whitehall outside Downing Street as they protest against the downgrading of A-level results. The government faced criticism after education officials downgraded more than a third of pupils' final grades in a system devised after the coronavirus pandemic led to cancelled exams yes AFP via Getty UK news in pictures 13 August Benita Stipp (centre) and Mimi Ferguson (left) react as students at Norwich School receive their A-Level results PA UK news in pictures 12 August 2020 A train derailment near Stonehaven has left three people dead. Driver Brett McCullough, conductor Donald Dinnie, and a passenger were killed when the 6.38am Aberdeen to Glasgow Queen Street service crashed amid heavy rain and flooding BBC UK news in pictures 11 August 2020 A woman hydrates in the sun after open water swimming at the West Reservoir Centre in north London Tolga Akmen/AFP via Getty UK news in pictures 10 August 2020 Prime Minister Boris Johnson takes part in an archery session as he visits Premier Education Summer Camp at Sacred Heart of Mary Girls' in Upminster Reuters UK news in pictures 9 August 2020 People cycle through Cambridge as the heatwave continues in Britain EPA UK news in pictures 8 August 2020 Healthcare workers take part in a protest in London over pay conditions in the NHS Getty UK news in pictures 7 August 2020 Emergency services make their way along the seafront on Bournemouth beach in Dorset on one of the hottest days of the year PA UK news in pictures 6 August 2020 Alison Murphy poses for a picture by husband Peter as she walks through a field of sunflowers in Altrincham, Cheshire PA UK news in pictures 5 August 2020 Pakistan's Abid Ali being bowled by England's Jofra Archer during day one of the First Test match at the Emirates Old Trafford, Manchester PA UK news in pictures 4 August 2020 The 'Timbuktu tumblers' from Kenya perform their balancing act on the Southsea waterfront as Zippos Circus reopens in Portsmouth Rex UK news in pictures 3 August 2020 Pelicans interact with a visitor in St James's Park in London PA UK news in pictures 2 August 2020 Lewis Hamilton drives with a puncture towards the finish line to win the Formula One British Grand Prix at Silverstone POOL/AFP via Getty UK news in pictures 1 August 2020 Arsenal's Pierre-Emerick Aubameyang celebrates with the trophy and teammates after winning the FA Cup, as play resumes behind closed doors following the outbreak of the coronavirus disease Pool via Reuters UK news in pictures 31 July 2020 People enjoy the sunny weather at a Bournemouth Beach Reuters

“We can only put it down to cuts and funding,” she added. “I can’t see how those messages would not have been disclosed if they had been seen.”

The barrister, of Furnival Chambers, said Mr Allan’s prosecution would have been “nipped in the bud” in light of the information, which was taken from the claimant in January 2016.

“If they had found what I found they would never have charged him,” she added.

“The police have a duty to investigate all reasonable lines of inquiry – if they do have a download they’re supposed to look at it.

“It means putting work in that might be laborious and take time, but it must be done.”

Ms Smart said the case was just one of four she is currently dealing with where evidence has not been disclosed or delayed, forcing lawyers to “fight” to obtain it in court.

One is an ongoing sexual assault case, where the discovery of 50,000 phone messages caused a delay to the trial.

A report issued in July by HM Crown Prosecution Service Inspectorate and HM Inspectorate of Constabulary said even unused items of evidence must be reviewed by police “to see whether it is capable of undermining the prosecution case or assisting the defence case”, adding: “If either factor applies it must be disclosed to the defence.”

Warning of “widespread failures” by both police and prosecutors, the authority said officers failing to comply with requirements were “often ignorant” of their disclosure responsibilities.

Those found filing incomplete record sheets told inspectors it was because of lack of time, limited resources and cumbersome IT systems.

It comes as the Home Office continues to rebuff funding requests from police forces across the country, telling them to make further savings amid a rise in 999 calls, recorded crime and the terror threat.

Trump links rise in UK crime to 'radical island terror'

Scotland Yard said it was “urgently reviewing” the investigation into Mr Allan and will be working with the CPS to understand what took place.

“Until that review is complete the Met will not comment about what has taken place and why,” a spokesperson added.

“However, the Met understands the concerns that have been raised as a result of this case being dismissed from court and the ongoing review will seek to address those.”

The CPS said police provided more detail in Mr Allan’s case in November that was reviewed and meant there was no longer a realistic prospect of conviction.

“Therefore we offered no evidence in the case against Liam Allan at a hearing on 14 December,” a spokesperson added.

“We will now be conducting a management review together with the Metropolitan Police to examine the way in which this case was handled.‎”

Campaigners emphasised that false rape allegations are rare in comparison to the publicity they receive, with the crime believed to be severely underreported.

Rachel Almeida, from Victim Support, said: “We are aware that false claims of this nature can cause significant harm to those accused, however it is important to highlight that untrue claims of rape are incredibly rare.

“Extensive research has shown this to be the case and that false reporting is actually lower for rape than for other offences.