Peter Bergen is CNN's national security analyst, a vice president at New America, a professor of practice at Arizona State University and the author of "Manhunt: The Ten-Year Search for bin Laden from 9/11 to Abbottabad."

(CNN) Retired Lieutenant General Michael ("Mike") Flynn's fall from grace has been precipitous. Flynn was once an admired Army Special Operations officer who went on to hold one of the most powerful jobs in the world as President Donald Trump's National Security Adviser.

On Tuesday Flynn appeared in federal court in Washington DC to be sentenced for lying to the FBI. According to Special Counsel Robert Mueller's sentencing memo filed earlier this month, because of his extensive cooperation with investigators as well as his more than three decades of public service, prosecutors are requesting a minimal sentence, including the possibility of no jail time for Flynn. On Tuesday Flynn's sentencing was delayed so he can continue cooperating with the Mueller investigation.

Flynn has spoken to prosecutors 19 times as part of his plea agreement, which underlines his value to Mueller as a witness because of his early involvement in the Trump campaign and the key role he played in the transition, all of which gives him important insights into the campaign's precise involvement with the Russians.

How did Flynn's long fall from grace happen? This story is based on interviews with multiple former colleagues of Flynn's in the military, as well as with his colleagues in the Trump White House. (I have also interviewed Flynn in the past, although he has not spoken to the media while awaiting sentencing.)

An intensely hard-working officer and effective leader

During his military career few could have predicted the path that Flynn would eventually take. As a colonel in charge of intelligence for Joint Special Operations Command (JSOC), Flynn was a well-loved, effective team leader and an intensely hard-working officer who was constantly deploying to Iraq and Afghanistan. Flynn used to joke that he lived at the JSOC base in Balad, Iraq, and took his vacations at the JSOC base in Bagram, Afghanistan.

The hours working for JSOC were brutal, 17-hour days every day of the week, but the mission was clear. Flynn and his boss, General Stanley McChrystal, understood by 2005 that the United States was losing the war in Iraq and that JSOC wasn't configured well enough to destroy the industrial strength insurgency it was facing, which was led by al Qaeda in Iraq.

Al Qaeda in Iraq wasn't a traditional military opponent operating with a top-down bureaucratic hierarchy, but rather a loose network of like-minded jihadists. McChrystal's mantra became "it takes a network to defeat a network."

To become a network, JSOC would have to get flatter and more agile. McChrystal and Flynn reconfigured JSOC so it communicated more seamlessly with all the components of the intelligence community and more quickly processed the intelligence gathered on raids so other raids could be immediately launched based on what was gleaned from the initial operation.

The results were startling; JSOC went from doing only four or five raids a month to doing hundreds every month, and al Qaeda in Iraq took a huge beating.

In 2012 Flynn, now promoted to lieutenant general, was appointed to run the Defense Intelligence Agency (DIA). Flynn wanted to turn DIA into something more like JSOC with more analysts deployed "forward" in the war zones.

This was an excellent idea. After all, if you are supposed to be providing intelligence on a war, it helps if you are not working in an office 6,000 miles from where the conflict is actually happening. But DIA is a bureaucratic behemoth of some 17,000 employees, most of whom are quite happy living in the Washington, DC, area as opposed to, say, working for a year at Bagram Air Base in the windswept, mountainous deserts of Afghanistan.

The DIA desk jockeys pushed back against Flynn and his plans to deploy many of them to the war zones. Flynn had never commanded a giant organization like DIA. The first rule of bureaucratic politics is if you want to make big changes you need to enlist folks to help, Flynn didn't make much of an effort to do this at DIA, which ruffled bureaucratic feathers and irritated his bosses at the Pentagon and in the intelligence community.

'Flynn facts' and conflicts with Obama team

At DIA, Flynn also began developing some eccentric notions. Flynn became convinced that the jihadist attack against the American consulate in Benghazi, Libya, in 2012 was orchestrated by Iran, which on the face of it made little sense since the Shia regime in Iran rarely cooperates with Sunni militants. There was also no evidence for this fanciful notion, but Flynn pushed his analysts at DIA to find a link that didn't exist.

It was Flynn's failures to distinguish between conjecture and truth that led analysts at DIA to coin the term " Flynn facts ."

When Flynn was running DIA, the Obama administration's view of the terrorism threat was best encapsulated by President Obama's statement to New Yorker editor David Remnick in January 2014 that the group that would evolve into ISIS was merely a "jay-vee" team.

Flynn had a far less sanguine view, warning that the global jihadist movement was not waning in the wake of Osama bin Laden's death, as was then the conventional analysis. Flynn made this case publicly in congressional testimony on February 11, 2014, when Sen. James Inhofe, a Republican from Oklahoma, asked him if al Qaeda was indeed on the run, as the Obama administration was claiming.

A few months later, Flynn made a similar public statement at the Aspen Security Forum, an annual conference held in July in Aspen, Colorado, that attracts top US national security officials and the journalists who cover them.

CNN's Evan Perez asked Flynn, "Are we safer today than we were two years, five years, ten years ago?"

"My quick answer is we're not," Flynn replied.

Flynn went on to say that focusing only on the declining fortunes of "core" al Qaeda, the group that had attacked the United States on 9/11, was to gloss over the fact that jihadist ideology was in fact "exponentially growing."

As ISIS conquered much of Iraq during the summer of 2014 and imposed its brutal, totalitarian rule, it was clear that Obama and his national security team had underestimated the strength of ISIS, while Flynn had understood the threat far better than many of his peers. But Flynn had angered his two bosses, Michael Vickers, the overall head of intelligence at the Pentagon, as well as James Clapper, the director of national intelligence.

Vickers and Clapper thought that Flynn trying to shake things up at DIA was actually sabotaging morale at the agency, according to Clapper's autobiography, "Facts and Fears." They decided to force Flynn out of office a year early.

Flynn in the civilian world

Flynn seems to have been both bitter and embarrassed about the way he had been fired. In his own mind he was forced out because he wasn't playing along with the Obama administration line that the war on terror was largely over, according to his autobiography, "The Field of Fight." For Vickers and Clapper, it was much simpler: They fired him because he was a bad manager.

Either way Flynn, a highly decorated officer with 33 years service in the army, much of it in Special Operations, at the age of 55 had his career abruptly ended -- and in an inglorious manner to boot.

Perhaps by way of compensation, once he was out in the civilian world, Flynn wanted to show that he was a rainmaker. Flynn set up Flynn Intel Group, which took on all manner of clients, a number of them with links to foreign governments.

Out of some combination of naiveté and arrogance Flynn, the maverick who came out of the "special" insular world of Joint Special Operation Command, did not play by the rules when it came to the lobbying work he did for some of his foreign clients, for which he was supposed to register officially as an agent of a foreign government. In Flynn's sentencing memo, the Special Counsel says that Flynn misrepresented his work on behalf of the Turkish government for which he and his company were paid more than half a million dollars.

Flynn also began dipping his toe into politics. After meeting with Donald Trump in August 2015 Flynn came away deeply impressed. Trump was a good listener; he asked smart questions and he seemed truly worried about the direction that the country was heading, according to an interview Flynn gave to The Washington Post.

Flynn became a prominent presence on the Trump campaign and a vocal critic of Obama's supposedly "weak" policies on ISIS. This, of course, dovetailed very neatly with what Trump was saying.

Flynn's support of Trump was all the more important because he was the only person on Trump's campaign team with any experience of America's post-9/11 wars that continued to grind on at various levels of intensity in Afghanistan, Iraq, Libya, Pakistan, Somalia, Syria and Yemen.

Like Trump, Flynn thought that the United States could work with Putin and even sat next to the Russian president at a gala dinner in Moscow in December 2015 that celebrated the 10th anniversary of Russia Today (RT), the Kremlin-sponsored TV network, an appearance for which Flynn was handsomely paid . The Russians, through his speaking agency, gave Flynn $33,750.

Flynn later told a Washington Post reporter that this wasn't a big deal, as RT was similar to CNN, a bizarre claim given that RT is effectively an arm of the Kremlin.

In the spring of 2016, Trump started to seriously consider Flynn as a possible candidate to be his running mate. The three-star general would certainly help on the commander in chief issue. At the time, the leading candidates to be Trump's running mate were former House Speaker Newt Gingrich, New Jersey Gov. Chris Christie and Flynn. Indiana Gov. Mike Pence was seen as only a distant possibility for the number two-slot on the ticket, according to a senior Trump campaign official.

Flynn made his first, big appearance on the public stage when he made a fiery speech of support for Trump at the Republican convention in Cleveland on July 19, 2016. Flynn angrily charged Obama and Clinton with endangering the United States and even lying about the nature of the terrorist threat: "Tonight, Americans stand as one with strength and confidence to overcome the last eight years of the Obama-Clinton failures such as bumbling indecisiveness, willful ignorance, and total incompetence...Because Obama chose to conceal the actions of terrorists like Osama bin Laden and groups like ISIS, and the role of Iran in the rise of radical Islam, Americans are at a loss to fully understand the enormous threat they pose against us."

As he spoke, Flynn led the crowd in chants of "U-S-A! U-S-A!" and incited them, "Get fired up! This is about this country!"

Flynn declared, "I have called on Hillary Clinton to drop out of the race because she put our nation's security at extremely high risk with her careless use of a private email server."

The crowd started chanting, "Lock her up! Lock her up!"

Hesitating only slightly, Flynn added his voice to the chants declaring, "Lock her up, that's right! Damn right, exactly right. And you know why we're saying that? We're saying that because, if I, a guy who knows this business, if I did a tenth of what [Clinton] did, I would be in jail today."

Officers who had served with Flynn were dismayed and puzzled by this performance, which went against their code not to take such clearly partisan positions, even in retirement. The angry man on stage didn't seem like the Mike Flynn they knew.

Growing enamored of neoconservatives and right-wing ideologues

Some of his peers felt Flynn had succumbed to a case of "Obama Derangement Syndrome" after he was fired from running the Defense Intelligence Agency. That might be a partial explanation for Flynn's impassioned rhetoric against Obama and Clinton, but in the years after he was pushed out of the military Flynn had also became enamored of leading neoconservatives and right-wing ideologues.

Flynn coauthored a book, "Field of Fight: How We Can Win the Global War Against Radical Islam and its Allies." with Michael Ledeen, a neoconservative academic who was a longtime, bitter critic of the Iranian regime. In "Field of Fight," which was published just before the Republican convention, Flynn claimed the United States was in a world war with "radical Islam," which it was losing. Flynn also claimed that American Islamists were trying to create "an Islamic state right here at home." This is a common conspiracy theory of the far right.

Flynn also wrote for the New York Post about a supposed "enemy alliance" that included Cuba, Iran, North Korea and Venezuela as well as al Qaeda, ISIS and the Taliban. This was George W. Bush's "axis of evil" on steroids and scarcely more convincing since ISIS and Iran were at war, as were al Qaeda and ISIS, and none of these terrorist groups had any relationship with the North Koreans or with leftist regimes in Latin America.

At the same time Flynn became increasingly gripped by rightist conspiracy theories. In August 2016 Flynn claimed in a speech that Democratic members of the Florida legislature were trying to install Sharia law in their state. This was, of course, nonsense.

Flynn also tweeted that fear of Muslims was "rational" and publicly said that Islam was really a "political ideology" rather than a religion. When he was in uniform, Flynn had never made these kinds of assertions about Muslims and Islam.

Flynn's inability to distinguish easily between facts and obvious falsehoods seemed to worsen as the presidential campaign continued. Flynn claimed in an interview with Breitbart News that there wer e Arabic signs along the United States-Mexico border to guide potential terrorists into the States and that he had seen evidence of these signs. Flynn said, "I have personally seen the photos of the signage along those paths that are in Arabic. They're like waypoints along that path as you come in. Primarily, in this case the one that I saw was in Texas and it's literally, it's like signs, that say, in Arabic, 'This way, move to this point.' It's unbelievable." It was unbelievable because it was completely false.

Unexpected victory

That Flynn seemed to have never really expected Trump to win the election was underlined by an article written by Flynn that appeared in The Hill newspaper on Election Day 2016 that compared Fethullah Gulen, a Turkish cleric living in in exile in Pennsylvania, to Ayatollah Khomeini.

For the government of Turkish President Recep Tayyip Erdogan, Gulen was an obsession. It had fingered Gulen for purportedly masterminding a botched military coup in Turkey in the summer of 2016.

Flynn's article suggested that Gulen, who had very good reasons to fear for his safety if he ever returned to Turkey, should not be allowed to remain in the United States.

No one who really thought he would be the next US national security adviser would have published such a provocative piece in a relatively obscure publication the very same day that his candidate was elected to the most powerful job in the world.

The article also risked drawing attention to the fact that Flynn's consulting firm had been paid more than half a million dollars by a company close to the Erdogan government, despite the fact that Flynn hadn't registered as an agent of a foreign government as is required by law.

Flynn's positions and actions during the campaign and the transition were not those of the typical national security adviser, but then nor were the president-elect's.

Two days after Trump was elected president, Obama sat down with Trump in the Oval Office and, among other matters, warned Trump against hiring Flynn in any senior role.

A week after meeting with Obama, though, Trump offered Flynn the key job of national security adviser. Flynn's loyalty to Trump and early support for him trumped questions about his temperament as well as his lack of experience managing the complex national security bureaucracy -- and the fact that he had never worked at the White House.

For more opinion... Sign up for our new newsletter. Join us on Twitter and Facebook

Mike Flynn was only 24 days in his job when he was forced to resign . The reason given: that he had lied to Vice President Mike Pence, telling him that during the transition he hadn't discussed lifting Obama-era sanctions against Russia with the Russian ambassador to the United States, when in fact he had. This lie appears to have been an effort to cover up the fact that Flynn was conducting substantive American foreign policy before he was ever in office. The United States operates on the principle that there is only one president at a time.

Flynn repeated the lies about the Russian ambassador to the FBI and compounded his legal jeopardy by lying about his links to the Turkish government in documents filed with the U.S. government, according to Tuesday's sentencing memo.

Those actions completed Flynn's fall from grace. No American National Security Adviser has served as briefly as Mike Flynn.