The judge in the Tulisa Contostavlos trial said evidence given by undercover reporter Mazher Mahmood was "entirely inconsistent".
Explaining his decision to throw out the trial, Alistair McCreath said the prosecution's case had become "tainted" by "serious misconduct".
Before the start of the trial, Contostavlos' lawyers had attempted to have the prosecution "stayed", meaning it would have been thrown out before beginning.
The court hear that there was a problem with evidence provided by a driver called Alan Smith, who originally said he had heart Contostavlos speaking disapprovingly about drugs when she was in his car.
He then "changed his mind", after a conversation with Mahmood, the court was told.
At a pre-trial hearing, Mahmood denied having had any conversation with Mr Smith about what Contostavlos had said.
But the judge said when asked about the same topic during the trial, Mahmood gave answers that were "entirely inconsistent".
The Sun has suspended undercover reporter Mazher Mahmood after the judge in the Tulisa Contostavlos drugs trial said there were "strong grounds" to believe he had "lied" at a pre-trial hearing.
A statement from the newspaper said: "We are very disappointed with this outcome, but do believe the original investigation was conducted within the bounds of the law and the industry's Code. This was demonstrated by the CPS decision to prosecute,
"The Sun, of course, takes the Judge's remarks very seriously. Mr Mahmood has been suspended pending an immediate internal investigation."
Tulisa Contostavlos has urged police to investigate undercover reporter Mazher Mahmood - known as the 'Fake Sheikh - and "put an end to his deceits".
She was speaking after her trial on drugs charges collapsed with the judge telling jurors there were "strong grounds to believe" that Mr Mahmood had "lied" at a pre-trial hearing.
Tulisa Contostavlos has thanked her fans and her lawyers following the "terrible ordeal" of her drugs trial.
She also said she was now looking forward to working again.
Speaking outside Southwark Crown Court after the trial collapsed, the former X Factor judge said: "I have not been able to work for a year and I'm now looking forward to resuming my career.
"I will use these experiences to make me stronger. I'd like to thank all the people who have supported me through this terrible ordeal, including my fans and, of course, my legal team."
The co-defendant in the the Tulisa Contostavlos trial has also walked free after the judge decided the case against him could not proceed.
Rapper Michael Coombs, whose stage name is Mike GLC, had pleaded guilty before the trial to supplying half a gram of cocaine to undercover reporter Mazher Mahmood.
On hearing the decision the 36-year-old reportedly wept and hugged his defence barrister, Jeremy Dein QC.
Tulisa Contostavlos punched the air with delight and hugged supporters after her trial was thrown out at Southwark Crown Court.
The former X Factor judge had been accused of brokering a cocaine deal with an undercover reporter, a charge she strongly denied throughout.
The judge threw out the case after deciding there were "strong grounds" to believe that the undercover reporter Mazher Mahmood had "lied" at a pre-trial hearing.
The judge in the trial of Tulisa Contostavlos told the jury there were "strong grounds" to believe an undercover reporter had "lied" at a hearing before the trial began.
Judge Alistair McCreath was speaking as he threw out the case at Southwark Crown Court.
The Sun's Mazher Mahmood - known as the 'Fake Sheikh' - had posed as a wealthy film producer when he met Contostavlos at a number of hotels and restaurants.
The former N-Dubz singer strongly denied that she had helped broker a drug deal between Mahmood and her rapper friend Michael Coombs, also known as Mike GLC.
The trial of former X Factor judge Tulisa Contostavlos has collapsed.
The singer was accused of helping to broker a drug deal between a friend and an undercover reporter known as 'the Fake Sheikh'.
The undercover reporter known as the "Fake Sheikh" has told the trial of Tulisa Contostavlos it was '"outrageous" to suggest he spiked the former X-Factor judge's drink.
Giving evidence at London's Southwark Crown Court, Mazher Mahmood, denied "manipulating" the 26-year-old after he told her she was being considered for a leading role in a Slumdog Millionaire-type film, possibly co-starring Leonardo Di Caprio.
The court previously heard that Contostavlos spoke about being able to get "white sweets" - allegedly code for cocaine - while at the Metropolitan Hotel with Mr Mahmood on May 10 last year.
The prosecution suggested that Mr Mahmood and his colleague "Nish" spiked Contostavlos's drink to "manipulate" her when they met at the hotel.
Mr Mahmood replied: "Absolutely outrageous."
Under further cross-examination, Mr Mahmood told a court he wanted to "expose criminality" and denied the reason for the expose was to create a "sensational story".
Tulisa, of Friern Barnet, north London, denies being concerned in the supply of class A drugs between May 10 and May 23 last year.
The jury was sent home and told to return to court on Monday.
Former X factor judge and N-Dubz star Tulisa told an undercover reporter she could get hold of "white sweets" in an apparent reference to cocaine, a court heard.
The singer "did not negotiate the price or amount" but "did all she could to make a supply of cocaine happen," prosecutor Tim Cray said.
He added Tulisa's role in the deal at London's Dorchester Hotel in May last year was "instrumental."
The trial at Southwark Crown Court continues.