NEW YORK — Democratic Party presidential candidate Hillary Clinton does not need to give sworn testimony in a lawsuit brought by a conservative watchdog group over her use of an unauthorized private email system while she was U.S. secretary of state, a judge ruled on Friday.

Clinton must instead respond in writing within 30 days to questions submitted by Judicial Watch, a group that has long been critical of her conduct and which is suing the Department of State over Clinton-era records.

Judge Emmet Sullivan’s ruling in U.S. District Court in Washington is likely to be a relief to Democrats, who did not welcome the prospect of Clinton having to submit to hours of questioning by lawyers in the middle of her campaign for the Nov. 8 election against Republican candidate Donald Trump.

Clinton, who served as the country’s top diplomat from 2009 to 2013, has apologized for her decision to use the unorthodox email setup, which had the effect of shielding her communications from public-records laws until the arrangement came to light last year.

Voters have said in opinion polls that the email server issue contributes to impressions that Clinton is untrustworthy. The Justice Department concluded last month there were no grounds to prosecute Clinton for the arrangement after a yearlong investigation.

Sullivan has allowed Judicial Watch to obtain sworn testimony in sometimes testy exchanges with several Clinton aides in recent months, saying the court needs to establish whether the server was set up to thwart the Freedom of Information Act.

But the judge agreed with Clinton’s lawyers that former high-ranking government officials can be ordered to give sworn testimony only in “exceptional circumstances.”

Sullivan also allowed Judicial Watch to get sworn testimony from a former State Department official named John Bentel.

According to a scathing report by the State Department’s inspector general, Bentel, then a technology official in Clinton’s office, told junior staffers to never speak of Clinton’s email server again after they raised concerns. Bentel and his lawyer have declined to comment on the episode.

A spokesman for Clinton could not immediately be reached for comment on Friday.

Judicial Watch said it was happy with the ruling.

“We will move quickly to get these answers,” Tom Fitton, the group’s president, said in a statement. “The decision is a reminder that Hillary Clinton is not above the law.”