WASHINGTON — Atty. Gen. William Barr told a Senate committee Wednesday that he is reviewing whether the Justice Department and the FBI acted inappropriately in their investigation of Russian election interference in 2016, saying he thought “spying did occur” on President Trump’s campaign.

In echoing the provocative charge leveled by Trump to denounce the court-approved surveillance of a former member of his campaign, Barr thrust himself directly into the partisan battle waged by the White House and Republican lawmakers who allege that abuses by FBI officials prejudiced the Russia investigation from the start.

Testifying to the Senate Appropriations Committee, the nation’s top lawman expressed concerns about whether top FBI officials at the time followed rules governing secret surveillance and whether those guidelines need to be reexamined.

Asked by a senator why the review was necessary, Barr said: “For the same reason we’re worried about foreign influence in elections.”

He added: “I think spying on a political campaign is a big deal.”

Barr said he wanted to know whether law enforcement had gathered adequate evidence to begin surveillance. Although he said he hadn’t made up his mind, he suggested that “there was probably a failure among a group of leaders” at the FBI’s “upper echelon.”

Barr told the Senate committee that he is close to releasing a redacted version of special counsel Robert S. Mueller III’s nearly 400-page report into Russia’s interference in the 2016 campaign and whether Trump obstructed justice in seeking to derail the probe.

The attorney general said the public version could be released next week, and said he was willing to work with lawmakers afterward to make some of the redacted information available to Congress.

A total of 34 people were charged as a result of Mueller’s investigation, including Trump’s former campaign chairman, his former national security advisor and his former personal lawyer. None were accused of working with the Russians, whom Mueller separately charged with hacking Democratic Party emails and spreading disinformation on social media in an effort to help Trump win.

Barr told Congress in a March 24 letter that Mueller did not establish a criminal conspiracy between the Trump campaign and the Kremlin.

Barr also said he did not believe the president had committed obstruction of justice. Mueller did not reach his own conclusion on the issue, Barr wrote in his letter.

Before leaving the White House on Wednesday for a daylong visit to Texas, Trump told reporters that Barr was “doing a great job” by probing the Russia investigation itself.

Trump praised Barr for “getting started on going back to the origins of exactly where this all started. Because this was an illegal witch hunt and everybody knew it. And they knew it too and they got caught. And what they did was treason.”

He added: “It was started illegally. Everything about it was crooked — every single thing about it. There were dirty cops. These were bad people.”

Democrats reacted to Barr’s comments with outrage, and Sen. Richard Blumenthal of Connecticut called on him to retract them.

“The only spies interfering in the 2016 campaign were Russian ones,” he said in a statement.

Blumenthal added, “I am deeply disappointed that Atty. Gen. Barr has so demeaned himself and his department by carelessly acting as a mouthpiece for President Trump’s conspiracy theories.”

Barr took office in February after a contentious Senate confirmation process. Democrats criticized him for previously writing a memo that called Mueller’s investigation into obstruction of justice “fatally misconceived,” and questioned whether he would be independent of White House pressure.

Barr’s inquiry is one of several into how investigations were handled during the 2016 campaign. Two of the internal Justice Department reviews are set to wrap up shortly.

The Justice Department inspector general is expected to complete as soon as next month its investigation of the secret surveillance of Carter Page, an oil industry consultant and a former foreign policy advisor to the Trump campaign.

Page was investigated for his repeated contacts with Russian government officials, including suspected intelligence operatives. He has not been charged with a crime.

Law enforcement had obtained a classified warrant to surveil Page from the Foreign Intelligence Surveillance Court, known as the FISA court, which operates in secret and must approve intelligence-related eavesdropping on U.S. citizens.

Republicans have argued that the warrant application was based on unsubstantiated information from a political adversary and thus should never have been submitted to the court for approval.

Some Trump allies have called for appointment of a separate special counsel to investigate whether the Justice Department and FBI relied too heavily on information supplied by Christopher Steele, a former British intelligence operative who also served as an FBI informant.

Steele, who wrote a controversial and colorful dossier on Trump, was hired and paid by Fusion GPS, a political research firm working on behalf of Democrats.

The Justice Department used Steele’s information, in part, to obtain a surveillance warrant from the FISA court starting in October 2016, shortly after Page left the campaign. The surveillance warrant on Page was renewed three more times by other FISA judges.

The last application presented to the FISA court was approved and signed in June 2017 by Deputy Atty. Gen. Rod Rosenstein, a Trump appointee.

Republicans say the Justice Department did not fully disclose who funded Steele’s research, leaving the FISA court in the dark about his motivations.

However, the application for the warrant states that the FBI had assessed that the research was probably being funded in the hopes of finding “information that could be used to discredit” Trump’s campaign.

The Justice Department typically does not identify U.S. citizens or organizations by name in such affidavits. Trump, for example, is identified as Candidate #1 in the affidavit.

Barr, like his predecessor, Jeff Sessions, has resisted Republican calls to appoint another special counsel. Instead, both opted to allow the inspector general to conduct an inquiry into how the Justice Department handled the matter.

A separate internal review is examining how the FBI and Justice Department conducted investigations into Hillary Clinton’s use of a private email server while she was secretary of State, the nonprofit Clinton family foundation and any potential links between the Clintons and a Russian nuclear energy agency. No one was charged in any of those inquiries.

That review is being led by John Huber, U.S. attorney for the District of Utah.

In a bit of irony, an FBI investigation into the Clinton Foundation was sparked by a book, “Clinton Cash,” which was published in 2015 and financed by a nonprofit group, the Government Accountability Institute.

The institute was heavily funded by Trump backers and was co-founded by Stephen K. Bannon, who served as Trump’s campaign manager, according to law enforcement officials who have confirmed a 2016 report by the Wall Street Journal on the investigation.