Giggs claimed that the newspaper "misused" private information and said he was entitled to claim damages for distress and breach of a right to privacy enshrined in human rights legislation.
Mr Justice Tugendhat said Giggs' claim for damages was unlikely to result in any "significant award" and concluded there was "no purpose" in allowing the litigation to continue.
Former Wales international Giggs, 38, sued after The Sun published an article about a relationship with reality television star Imogen Thomas - headlined "Footie Star's Affair with Big Bro Imogen" - on April 14, 2011.
The litigation became "famous" shortly afterwards when a judge ruled that Giggs should not be identified - but referred to as "CTB" - to protect his privacy.
In May, Liberal Democrat MP John Hemming used parliamentary privilege to name Giggs as the player involved in the case, speaking in the Commons.
Giggs was subsequently named in the media and on the internet, even though the court order banning identification remained in place for several months.
He was first named in court earlier this year after a judge said the anonymity order was no longer needed.
Mr Justice Tugendhat heard legal argument about whether the action should be allowed to continue at a High Court hearing in February.
Hugh Tomlinson QC, for Giggs, argued that The Sun had misused private information in the article, in which Giggs was not identified.
Mr Tomlinson said Giggs was claiming damages for the subsequent republication of information in other newspapers and on the internet, and argued that his claim should go to trial.
Richard Spearman QC, for The Sun's publisher, News Group Newspapers, said the article had reported Ms Thomas' relationship with a Premier League player and had not identified Giggs.
He said The Sun had behaved "properly" and was not responsible for what had happened after the article appeared.
Mr Spearman said the damages claim was "dead in the water" and told the judge: "Going forward, there just is not a basis."
Mr Justice Tugendhat sided with The Sun.
"It cannot be said that the claim for damages could give rise to any significant award, even if it could give rise to an award at all," said the judge, in a written ruling handed down at a hearing in London.
"There is in my judgment no purpose to be served by granting relief ... and I would refuse to do so."
The judge said the litigation had become "notorious".
"There can be few people in England and Wales who have not heard of this litigation," he said.
"The initials CTB have been chanted at football matches when Mr Giggs has been playing for Manchester United.
"And Mr Giggs has been named in Parliament, raising questions as to the proper relationship between Parliament and the judiciary."
He added: "The proceedings were famously anonymised and Mr Giggs was referred to as CTB.
"What is famous or notorious about this litigation is that the order for Mr Giggs to be anonymised did not achieve its purpose."
Giggs also took legal action against Imogen Thomas. That claim was settled last year. David Price QC, for Ms Thomas, told Mr Justice Eady at a High Court hearing in London on December 15: "(Giggs) and Ms Thomas have now resolved matters between them."