The author of a New York Times editorial will have to testify under oath in a defamation lawsuit filed by the former vice-presidential candidate Sarah Palin, a federal judge ruled on Thursday.

The Times filed a motion last month seeking to dismiss the case, and the judge, Jed S. Rakoff of Federal District Court for the Southern District of New York, said the testimony was necessary to help him determine whether to grant that motion. Judge Rakoff set the hearing for Aug. 16. Judge Rakoff said last month that he would rule by the end of this month on the motion to dismiss the case.

A spokeswoman for The Times said in a statement that the news organization would provide the testimony the judge had ordered. David McCraw, deputy general counsel for The Times, said the witness would be James Bennet, The Times’s editorial page editor.

In the lawsuit, which was filed in June, Ms. Palin contends that The Times “violated the law and its own policies” when it linked her in an editorial to a mass shooting in January 2011. The editorial was published online on June 14, the same day that a gunman opened fire at a baseball field where Republican congressmen were practicing, injuring several people including Representative Steve Scalise of Louisiana.