The family residence of Kerry Khan in Alexandria, Virginia. This property is part of the assets that have been forfeited during the investigation. (Courtesy of Department of Justice)

He was a career federal bureaucrat with a dark side, inflating government contracts by millions of dollars and then shaking down contractors for the proceeds. The money funded a lavish and sordid lifestyle — a real estate empire in Northern Virginia, leased BMWs, Neiman Marcus shopping sprees, and mistresses in three states and the Philippines.

On Thursday, a federal judge sentenced Kerry F. Khan, the mastermind of a contracting scam of “historic proportions,” to nearly two decades behind bars. It was even more than prosecutors had requested because of the “staggering” scope of the scheme. U.S. District Judge Emmet G. Sullivan said he also wanted to deter other would-be criminals in the billion-dollar world of federal contracting.

“You made history for the wrong reasons,” Sullivan told Khan, 55, a former Army Corps of Engineers program manager and the ringleader of a network of corrupt public officials and government contractors who stole more than $30 million through inflated billings and fake invoices.

U.S. Attorney Ronald C. Machen Jr. has called it the largest bribery and bid-rigging scheme in federal contracting history.

The case revealed deep flaws in the oversight of federal contracts and prompted a review at the Army Corps of Engineers. Officials added new layers of review in the Army Corps’ contracting office, with senior managers and peer panels now responsible for scrutinizing all bids and solicitations before contractors are selected.

“The business of our town is government, and with government comes government contracts — lots of government contracts,” Assistant U.S. Attorney Michael Atkinson told the judge Thursday, urging him to send a message to thousands of public officials and contractors who must decide daily “whether to give in to the temptation of government corruption.”

The investigation, which prosecutors say is continuing, has led to admissions of guilt from more than a dozen people, including Khan’s brother and son. When Khan was arrested in October 2011, he had been paid more than $12 million in kickbacks and was owed more than $14 million from two subcontractors.

The previous year, Khan had received a stellar job-performance evaluation that said he had demonstrated “complete loyalty to the organization” and possessed “unquestionable integrity.”

Prosecutors said Khan was motivated by “greed on a massive scale.” Over more than four years, Khan and another Army Corps program manager, Michael A. Alexander, steered business to corrupt contractors, who in turn paid bribes to the two officials. Most of the time, the subcontractors delivered legitimate equipment and services. But under Khan’s direction, they inflated their bills to include “overhead” that, once paid, they kicked back to Khan and Alexander.

From spring 2007 through fall 2011, the Army Corps awarded more than $45 million in work to a Chantilly-based security services firm, Nova Datacom. Of that, nearly half was “overhead” funneled to Khan and his co-conspirators.

Alexander was sentenced last fall to 72 months in prison.

In addition to building himself a mansion in Alexandria, Khan bought a 3,025-square-foot home in Fairfax, wooded property near Lake Barcroft, three Falls Church condominium units — including one that advertised a view of the Washington Monument — and a home near the beach in Cape Coral, Fla.

Khan had a dark personal side, too, prosecutors said, pointing to text messages and wiretapped phone calls that investigators were monitoring that appeared to show his involvement in a violent assault on his girlfriend in the Philippines.

“Yeah, you did a good job, man, good job,” Khan told an associate in the Philippines who seemed in the phone call to take credit for the assault.

Khan’s text messages, detailed in his sentencing memo, also suggested that he had arranged a trip to the Philippines to meet a girl authorities said was a 15-year-old prostitute. Law enforcement officials claim to have disrupted the liaison without tipping their hand to the larger investigation.

In court Thursday, Sullivan was clearly troubled by the text messages, describing them as “shocking, vicious, cruel.”

Khan and his attorney did not dispute the content of the messages. Khan did not offer a specific reason for his overall conduct. But he told the judge that he was “going through a very dark period in my life,” and he said,“I deeply regret this.”

With two rows of family members watching in the courtroom, Khan also said he had been transformed during his time in the D.C. jail and hopes some day to make amends for his crimes.

According to prosecutors, Khan was also thinking ahead to retirement. When the contract that paid Nova Datacom was set to expire, he tried to ensure that a government selection panel would pick the company for more work.

And when he decided to resign in July 2011, he and Alexander discussed the need to find a “trusted” co-worker to chair the panel for the contract, which they hoped would reach nearly $1 billion over a five-year-period.

That month, Khan co-opted a colleague, according to prosecutors, paying more than $56,000 to lease a 2012 convertible BMW that the co-worker later drove to and from Army Corps headquarters on G Street NW in the District.

Khan has been locked up at the D.C. jail since his arrest; he pleaded guilty in May to money laundering and accepting bribes.

Defense attorney Jeffrey D. Zimmerman had argued that Khan should be sentenced to 10 years in prison, consistent with his co-conspirators’ sentences and taking into consideration his extensive cooperation. Khan has provided information about bribes to another unidentified public official at the Department of the Army, who prosecutors have said is a subject of the ongoing investigation.

But Sullivan said that even the government’s recommended 15-year sentence was “too lenient” because of the “staggering amount” of money Khan took for himself — and because of his role as ringleader. Sullivan sentenced Khan to 19 years and seven months in prison and ordered him to pay $32.5 million in restitution.

Investigators uncovered the Army Corps scam while looking into unrelated fraud at Nova Datacom. The company’s founder, Young N. “Alex” Cho, tipped off investigators and agreed to wear a wire.

But Khan’s greed was so “insatiable,” prosecutors said, that the investigation was cut short because his “cash demands from Cho were too great” for the government to continue fronting the bribe money, according to the government’s sentencing memo.

On the morning of his arrest, Khan had scheduled a meeting with Cho at Khan’s Falls Church condominium for Cho to transfer $6 million in bribe proceeds into Khan’s account.