A federal judge in Manhattan on Tuesday dismissed Sarah Palin's defamation lawsuit against the New York Times.

"Nowhere is political journalism so free, so robust, or perhaps so rowdy as in the United States," Judge Jed Rakoff wrote in an opinion dismissing the case. "In the exercise of that freedom, mistakes will be made, some of which will be hurtful to others."

The New York Times celebrated the decision.

"Judge Rakoff's opinion is an important reminder of the country's deep commitment to a free press and the important role that journalism plays in our democracy," a Times spokesperson said in a statement. "We regret the errors we made in the editorial. But we were pleased to see that the court acknowledged the importance of the prompt correction we made once we learned of the mistakes. In the words of the court, 'if political journalism is to achieve its constitutionally endorsed role of challenging the powerful, legal redress by a public figure must be limited' to cases where there is something more than an honest mistake."

Palin sued the newspaper earlier this summer over an editorial that drew a link between an advertisement from Palin's political action committee and a 2011 shooting in Tucson, Arizona, in which six people were killed and then-Congresswoman Gabrielle Giffords was severely wounded.

In the editorial, which was published online the day of the shooting at a congressional baseball practice this June, the editorial board suggested that Jared Lee Loughner, the man who carried out the Tucson massacre, was incited by a map from Palin's PAC's ad, which placed crosshairs over the congressional districts of several Democratic lawmakers, including Giffords'.

There is, in fact, no evidence that Loughner even saw the map, much less that he was motivated by it. The Times issued a correction the next day, but Palin filed her suit two weeks later.

Related: 'We're sorry': New York Times issues correction to editorial after controversy

Although it owned up to its error, the Times vowed to fight the case, asserting that the First Amendment protects its writers in such cases. Palin's attorneys argued that James Bennet, the editorial page editor who wrote the offending language in the piece, had displayed a reckless disregard of the facts, and claimed that the Times had an economic incentive to invoke Palin's name for clicks. In a motion to dismiss the case, lawyers for the Times called this premise implausible.

On Tuesday, Rakoff ruled in favor of that motion.

"Responsible journals will promptly correct their errors; others will not," Rakoff wrote. "But if political journalism is to achieve its constitutionally endorsed role of challenging the powerful, legal redress by a public figure must be limited to those cases where the public figure has a plausible factual basis for complaining that the mistake was made maliciously, that is, with knowledge it was false or with reckless disregard of its falsity. Here, plaintiff's complaint, even when supplemented by facts developed at an evidentiary hearing convened by the Court, fails to make that showing."

Lawyers for Palin did not respond to a request for comment.

In a hearing earlier this month, Bennet testified that he "did not intend to imply a causal link" between the map from Palin's PAC and the Giffords shooting. He said that he did a substantial re-write on the piece after the first draft was filed by Elizabeth Williamson, a member of the Times' editorial board based in Washington, D.C.

Related: New York Times editor testifies in Sarah Palin lawsuit

Williamson had written that both the 2011 deadly episode in Tucson and the June 2017 shooting in Alexandria, Virginia, which left Rep. Steve Scalise severely hurt, were "nurtured in a vile political climate." In 2011, Williamson wrote, "it was the pro-gun right being criticized" over the ad, which she said "put Ms. Giffords and 19 other Democrats under stylized cross hairs."

Williamson wasn't accurate in her description of the map, which only only placed those Democrats' districts under the cross hairs, not the Democrats themselves. But the reference to "incitement" didn't come until Bennet re-wrote the piece.

"Was this attack evidence of how vicious American politics has become? Probably," the editorial read. "In 2011, when Jared Lee Loughner opened fire in a supermarket parking lot, grievously wounding Representative Gabby Giffords and killing six people, including a 9-year-old girl, the link to political incitement was clear. Before the shooting, Sarah Palin's political action committee circulated a map of targeted electoral districts that put Ms. Giffords and 19 other Democrats under stylized cross hairs."

At the hearing earlier this month, Bennet told Palin attorney Ken Turkel that the editorial was written under a tight deadline, and that he didn't know whether Loughner had seen the map from Palin's PAC, nor was he aware of the reporting indicating that there was no clear link between Loughner and political incitement. He also said he was shocked to see readers thought the editorial accused Palin of contributing to Loughner's actions.

Turkel and fellow Palin attorney Shane Vogt, both of whom represented pro wrestler Hulk Hogan in his invasion of privacy lawsuit against Gawker last year, asserted that Bennet turned "a blind-eye to the truth," and that the Times editorial board used the June shooting "as a pulpit to advance their narratives on gun control and political rhetoric."

Palin's attorneys also made extensive reference to a 2010 column by the New York Times' Charles Blow, who wrote at the time that liberals talk about the former Alaska governor to "drive viewership and Web clicks."