The espionage trial for ex-CIA worker, Joshua Schulte (pictured), 31, who was charged with leaking secrets published by WikiLeaks in 2017, is wrapping up Tuesday

Federal prosecutors on Monday painted a software engineer on trial in the largest leak of classified information in CIA history as a disgruntled employee who was 'prepared to do anything' to betray the agency, as a defense attorney argued the coder had been scapegoated for a breach that exposed secret cyberweapons and spying techniques.

A Manhattan jury heard conflicting portrayals of Joshua Schulte, a 31-year-old former CIA employee accused of sending the anti-secrecy group WikiLeaks a massive cache 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 US 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.

At the start of the trial, Shroff said Schulte was an 'easy target' to try to pin the leak on because he 'antagonized almost every person there' before quitting for a $200,000-a-year position at a company in New York.

'He really was a difficult employee, but being a difficult employee does not make you a criminal. A difficult employee does not translate to being a traitor. A difficult employee does not translate to somebody who would sell out their country. Josh Schulte's not a traitor,' she said.

The four-week trial raised more questions than it answered and exposed alarming security lapses within the agency, she said.

The prosecution has portrayed Schulte as a disgruntled employee bent on getting back at the CIA by exposing its secrets, but the defense painted him as a 'difficult' employee who had been scapegoated

'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 later today. 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 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 US 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.'

A CIA computer engineer - and Schulte's one-time friend - testified that the release of the leaked materials by WikiLeaks in 2017 was 'crippling' to the Agency and required a week of 20-hour workdays to asses the scope of the damage, protect overseas assets and decide how to begin rewriting programs that target foreign adversaries.

Authorities said the leak (file image of WikiLeaks) was 'instantly devastating' to America's interests abroad, he said, because it exposed CIA operatives, brought intelligence gathering to a halt and left allies wondering whether the US could be trusted with sensitive information

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.