In the fall of 2015, the head of Air Force intelligence got an odd pitch from a supposed deep cover operative.

The man said he was going undercover at various companies to ferret out would-be leakers and spies. He wanted the Air Force involved.

Then-Lt. Gen. Robert Otto said the man, who had gotten in touch through another high-ranking Air Force official, spouted “all kinds of names and facts” and claimed other powerful people were on board.

Otto was skeptical.

“It just sounded — the technical term is ‘fishy,’ ” he said.

The military leader started asking around. By the time he met with the man a few months later, Otto was wearing a wire for the FBI. He had concluded that the program was a fraud.

That meeting helped unravel a years-long scheme by Garrison Courtney, a onetime spokesman for the Drug Enforcement Administration who managed to burrow into the intelligence community, roping in more than a dozen public officials and as many defense contractors along the way.

Pretending to be with the CIA, Courtney convinced contractors to hire him as cover for a ­top-secret program; he promised government reimbursement for his salary and a chance at lucrative contracts. By the time the scheme was uncovered in the spring of 2016, he had gotten a government procurement job that positioned him to make good on those promises. Prosecutors say that beyond the $4.5 million he fleeced over four years, he had a list of $3.7 billion in contracts he hoped to influence.

“If you’re extremely brazen and arrogant . . . and diabolical, there is a lot you can get away with,” said G. Zachary Terwilliger, U.S. attorney for the Eastern District of Virginia. “It’s a huge teachable moment for the government.”

On Wednesday, the 44-year-old Tampa man apologized for the “fear and chaos” as he was sentenced in federal court in Alexandria, Va., to seven years in prison for a single count of wire fraud.

His attorney, Stuart Sears, said Courtney pocketed only $1 million; the rest went to maintaining the fraud. “At the height of Mr. Courtney’s conduct in this case . . . he was living in a three-bedroom condo” with his second wife and three of his five children, Sears said.

Courtney told some people, including Otto, that he was trying to stop the next Edward Snowden. Others thought he was supporting secret military maneuvers in Africa or fighting Chinese commercial espionage. To some people, he was flashy, bragging falsely about being a sniper in Iraq, but to others, he was serious-minded. People who worked with Courtney said he was good at isolating them; it was never clear who knew what. And the classified nature of the project made it potentially illegal to ask.

Some of Courtney’s victims still won’t talk to law enforcement for fear of revealing classified information; others who did cooperate still think there was a real program that went off the rails. Even after a June guilty plea, Courtney claimed to his then-employer that he was a “burned Agency asset” who could help the military shipbuilder get intelligence contracts, according to court records.

Prosecutors say definitively that Courtney was never in the CIA. He did serve in the National Guard and the Army, although not in combat, and he worked as a spokesman for the Department of Homeland Security before moving to the DEA.

But when he left public service in 2010, divorcing from his first wife and struggling to build a career in the private sector, Courtney started to embellish. He was no longer just an ex-flack but a spy.

One Herndon, Va., defense contractor said in an interview that Courtney was quickly let go from the company in 2013 after staff determined that he had faked an email involving a DEA contract. Courtney found more luck after landing at Blue Canopy, a cybersecurity firm in Reston, Va., now owned by Jacobs Engineering.

While there, court records say, he developed the idea Judge Liam O’Grady described as “so creative, so imaginative that it had great power and as a result caused such danger to our country.” A group of small defense contractors would come together to pursue classified projects as part of a secret task force, with him and an associate on payroll.

“The premise was entirely plausible,” Courtney wrote in a letter to the court. “I manipulated my friends and acquaintances, with the lies becoming more complex over time, in order to bolster the ‘programs’ importance.”

During the scheme, Blue Canopy grew frustrated the government was not paying $2 million it said it was owed in contracts, and the company in 2015 hired lawyers to get the payment. Weaving a story about a complex intelligence operation, Courtney convinced an investment firm to pay Blue Canopy with the understanding the money would be reimbursed, according to a civil lawsuit filed by the company that financed the deal. Bolstering the claim was the fact that these meetings took place in secure government facilities, with real public officials involved. Jacobs ultimately settled the suit.

A Jacobs spokeswoman said Blue Canopy “was a witness to, and victim of, Garrison Courtney’s criminal conduct.” Courtney’s associate said he, too, is a victim who understood his role to be the “bad guy” pushing back when people questioned the effort. He said in an interview that he was cleared of all wrongdoing and should get “credit” for “a red flag operation” that exposed vulnerabilities in the system.

The secret task force concept was “kind of sketchy,” said Norman Hayes, a former rear admiral in the Navy who was working for a defense contractor when he met with Courtney, his associate and others in 2015. “But they had incredible access.”

Hayes said he did convince his company that they should not put Courtney and the associate on their payroll, saying that was not how classified programs worked. But when Hayes changed jobs and began working for another contractor, he said, he learned that both men were already being paid by his new employer.

Courtney, he emphasized, didn’t “take you out to Waffle House.” They met in secure facilities at the National Geospatial-Intelligence Agency and at Riverside Research, a nonprofit that does scientific research for the government, he said. Both required extensive background checks. And in the room were current and former high-ranking government officials.

“We were in there with some major companies that were sitting right next to us, CEOs of companies,” said Ed McDonald, who ran a small Gainesville, Va.-based contracting firm with his wife that was defrauded by Courtney. “I was like, ‘Well, if they’ve already validated it, who am I to question it?’ ”

Some officials were unaware they were involved in any kind of task force, real or otherwise, according to the government. They thought they were giving generic briefings on classified contracting needs, which Courtney then spun to victims.

But others became intimately involved, helping embed the fraud in the government just as Otto and others were trying to unravel it.

“This was literally an almost, nearly impossible case to investigate,” Terwilliger said. Doing so involved 10 agencies.

Two high-ranking Air Force officials, one a member of the senior executive service in charge of geospatial intelligence and the other a colonel dealing with nuclear surveillance, took charge of the program in 2015, according to people familiar with the investigation not authorized to discuss details. An attorney for one said that “two senior intelligence officials” gave the direction to straighten out a classified program that was not adhering to protocols.

Through attorneys, both say their superiors were fully aware of their involvement in the program and expressed no concerns about it. Otto and an Air Force spokeswoman said top officials made clear the Air Force should not be part of the program.

As FBI agents and companies that had yet to be paid for these supposed contracts started asking questions, they were told by high-ranking officials that any investigation would imperil national security and violate the law, according to court records. Prosecutors say Courtney was working on a classification guide that would make talking about the task force a crime; people familiar with the case say the colonel and an employee of the Director of National Intelligence who dealt with highly sensitive programs were involved.

“So many people believed in it and were determined for the ‘program’ to succeed,” Courtney told a probation officer, according to court records. “It seemed to me like the program was actually on the verge of becoming real or legitimate given who was involved and how it was operating.”

In fact, Hayes and other victims said several of the companies involved did land major intelligence contracts by working together.

Prosecutors say Courtney was hired at a nonprofit that matches the description of Riverside Research. The position gave Courtney leverage to get hired at the National Institutes of Health Information Technology Acquisition and Assessment Center, where he had the power to make good on his promises by steering government contracts. He directed one such contract to the nonprofit, prosecutors say, convincing NITAAC that for national security reasons, there could be no competition.

An attorney for Riverside declined to comment.

Victims blame the government for letting Courtney in, saying they had far less capacity to check his bona fides. Prosecutors say Courtney did not have a ­top-secret security clearance, but victims saw him enter secure facilities with what appeared to be the proper badges.

“The government should be held responsible as much if not more than Garrison himself,” McDonald said. “It’s unbelievable for one person to manipulate all these smart people who have been in the government for so many years. Maybe you dupe me, maybe you dupe my wife, but you’re not going to dupe 14 major companies.”

Hayes agreed.

“When I pass my security clearance to a government agency in a government building, that’s a fraud way beyond one person,” he said. “That’s a fraud put on by the U.S. government.”

Alice Crites, Shane Harris and Missy Ryan contributed to this report.