A software engineer on trial in the largest leak of classified information in CIA history was “prepared to do anything” to betray the agency, federal prosecutors said Monday as a defense attorney argued the man had been scapegoated for a breach that exposed secret cyberweapons and spying techniques.

A Manhattan jury heard conflicting portrayals of Joshua Schulte, a former CIA coder accused of sending the anti-secrecy group WikiLeaks a large portion of the agency's computer hacking arsenal — tools the agency had used to conduct espionage operations overseas.

Schulte left a trail of evidence despite learned attempts to erase his digital fingerprints, Assistant U.S. Attorney Matthew Laroche said in closing arguments. Schulte became disgruntled at the CIA, he said, and took meticulous steps to plan — and cover up — the 2016 theft.

“He was the only one who had the motive, the means and the opportunity to steal the information," Laroche said. "He was prepared to do anything to get back at the CIA.”

Defense attorney Sabrina Shroff called Schulte a patriot who was wrongly accused by an agency under intense pressure to solve the embarrassing leak. The four-week trial raised more questions than it answered and exposed alarming security lapses within the agency, she said.

“The government cannot tell you which of the many people with access to this data” stole the classified archive, she said. “It wasn't Mr. Schulte who did this.”

Jurors are expected to begin deliberating Tuesday. Schulte faces counts of illegal gathering of national defense information, unauthorized computer access, theft of government property and making false statements, among other charges.

Schulte, 31, worked for a CIA group in Langley, Virginia, that designs computer code to spy on foreign adversaries. The so-called Vault 7 leak revealed how the CIA would hack Apple and Android cellphones in overseas spying operations.

Prosecutors have said the leak was devastating to national security, as it exposed CIA operatives, brought intelligence gathering to a halt and left allies wondering whether the U.S. could be trusted with sensitive information.

“The defendant was prepared to burn down the United States government,” Laroche said. “He is an angry and vindictive man.”

The government settled too hastily on Schulte as the leaker, Shroff said, ignoring suspicious activity by one of his colleagues who was ultimately suspended. The prosecution theory has “giant holes,” she said, including the unresolved question of why WikiLeaks waited nearly a year to publish the archive.

The data was stolen from a CIA network that was so insecure — one witness called it “the wild wild west” — that investigators could not trace the leak with any certainty, she said.

But prosecutors said a sequence of subterfuge implicated Schulte, including deleting computer logs from his CIA work station and restoring administrator privileges from which the agency had stripped him. He made dozens of searches for WikiLeaks in the ensuing months and became “obsessed” with whether his leak had been published, prosecutors said.

Schulte also is accused of trying to leak secrets after his arrest by using a contraband cellphone in the federal lockup where he is being held and creating encrypted email and secret social media accounts.