Retired Lt. Gen. Michael Flynn speaks in Cleveland on the first day of the Republican National Convention. (Chip Somodevilla/Getty Images)

In campaign appearances for Donald Trump, retired Lt. Gen. Michael T. Flynn has cast the presidential race as a continuation of the career he spent battling dangerous enemies in distant wars.

“The enemy camp in this case is Hillary Rodham Clinton,” he said at a rally in Florida this month, pointing his thumbs down in disgust. “This is a person who does not know the difference between a lie and the truth. . . . She is somebody who will leave Americans behind on the battlefield.”

As chants of “Lock her up!” rose from the crowd, Flynn nodded with enthusiasm and said he was “so proud, standing up here, to be an American.”

It was a jarring moment in a race full of them — a retired three-star general comparing a presidential candidate to the al-Qaeda militants he faced in Afghanistan and Iraq, calling for a former senator and secretary of state to be imprisoned.

The appearance was only the latest eyebrow-raising episode involving Flynn, 56, who was one of the most respected military intelligence officers of his generation but who has spurned the decorum traditionally expected of retired U.S. flag officers and become the only national security figure of his rank and experience to publicly align himself with Trump, the Republican nominee.

Flynn vaulted to public attention with his convention speech. (Republican National Convention)

The unruly 2016 campaign has drawn dozens of former senior national security officials into the fray, including 50 who served Republican presidents and who this month signed a letter saying Trump “lacks the character, values and experience” to be president. Denunciations of Trump from retired Marine Gen. John Allen — who spoke at the Democratic National Convention — and former acting CIA director Michael J. Morell struck some as compromising their former institutions’ apolitical role in American democracy.

But Flynn, who vaulted to public attention with his speech at the Republican National Convention last month, has rattled even some of his most long-standing colleagues, engaging in harsh, partisan rhetoric that, to his critics, seems to clash with the principles and values he spent a career defending.

He has called President Obama a “liar,” declared the U.S. justice system “corrupt” and insisted that he was pushed out of his assignment as director of the Defense Intelligence Agency because of his views on radical Islam. The claim has left former superiors seething, including Director of National Intelligence James R. Clapper Jr., according to current and former officials who said Flynn was removed because of management problems.

Like Trump, Flynn has advocated forging closer ties with Russia. In interviews with The Washington Post, Flynn acknowledged being paid to give a speech and attend a lavish anniversary party for the Kremlin-controlled RT television network in Moscow last year, where he was seated next to Russian President Vladi­mir Putin.

“People went crazy,” said retired Brig. Gen. Peter B. Zwack, a former U.S. military attache in Moscow. “They thought it was so out of bounds, so unusual.” Zwack emphasized that he considers Flynn a “patriot” who “would never sell out his country.”

Flynn, who was no longer in government but received a DIA briefing on Russia before the trip, said the invitation and payment came through his speaker’s bureau. He said he used the visit to press for collaboration on Syria, Iran and the Middle East, and dismissed the ensuing controversy as “boring.” Asked why he would want to be so closely associated with a Kremlin propaganda platform, Flynn said he sees no distinction between RT and other news outlets.

“What’s CNN? What’s MSNBC? Come on!” said Flynn, who also has appeared occasionally as an unpaid on-air analyst for RT and other foreign broadcasters.

Flynn, center left, sits next to Russian President Vladimir Putin at an event last year to mark the Kremlin-controlled RT television network’s 10th anniversary. (Michael Klimentyev/Sputnik via Associated Press)

Dismayed by Flynn’s behavior since he left the military, former colleagues have contacted him to urge him to show more restraint. Among them are retired Gen. Stanley A. McChrystal, who relied heavily on Flynn in Iraq and Afghanistan, and retired Adm. Michael Mullen, a former chairman of the Joint Chiefs of Staff. McChrystal declined to comment for this article.

Mullen provided a written statement saying that “for retired senior officers to take leading and vocal roles as clearly partisan figures is a violation of the ethos and professionalism of apolitical military service.” Officers are sworn to execute orders without regard for political positions, an oath to the Constitution that “is inviolable and presidents must never question it or doubt it,” he said.

Flynn and Allen “have violated this principle and confused that clarity,” Mullen said. “This is not about the right to speak out, it is about the disappointing lack of judgment in doing so for crass partisan purposes. This is made worse by using hyperbolic language all the while leveraging the respected title of ‘general.’ ”

Allen noted that retired U.S. military officers have frequently taken public positions in presidential campaigns, including a number of recent chairmen, and that he did so out of concern with Trump’s calls for resuming the use of torture, killing families of terrorism suspects and mass-bombing cities in Syria.

“Retired senior officers should not take lightly the impact of public commentary in a political environment,” Allen said. “I chose to do so because I believe that Trump was proposing policies and orders to the U.S. military as a potential Commander in Chief, which I believed would create a civil-military crisis. This is a matter of conscience for me, because in moments of crisis such as these, credible voices must speak out.”

In interviews, Flynn said he respects his former superiors but rejected their entreaties as attempts to silence him and impinge on his free speech rights. “When someone says, ‘You’re a general, so you have to shut up,’ ” he said, “I say, ‘Do I have to stop being an American?’ ”

Flynn dismisses his critics as closet Clinton supporters or misguided colleagues who have put their pursuit of corporate board seats and lucrative consulting contracts ahead of their concern for the country. Most retired generals “are afraid to speak out,” he said, because they use their stars “for themselves, for their businesses.”

Flynn said his foray into politics began last year when he volunteered to advise five Republican candidates. He said that he first met Trump 11 months ago and that he spoke with him by phone several times before being asked to speak at the Republican convention.

Trump is a “very serious guy. Good listener. Asked really good questions,” he said. Flynn’s role in the campaign has yet to be defined. He said he has never met with Trump’s foreign policy adviser, Carter Page, and has not been promised any position if the real estate developer wins.

Flynn’s credentials and backing of Trump have fueled speculation that he could be in line for a high-level national security job if Trump is elected. He was briefly considered a potential Trump running mate before the candidate picked Indiana Gov. Mike Pence.

Rather than scaling back, Flynn, a registered Democrat, has become an avid campaigner for Trump whose views and impulses increasingly echo those of the Republican candidate.

He sees the nation as beset by darkness and corruption, with voters split between “centrist nationalists” and “socialists.”

The divide has weakened the nation’s ability to grasp what he considers an existential threat from “a diseased component” of Islam. “There’s something going on in the Muslim world,” he said. “Why do we have heightened security at our airports? It’s not because the Catholic Church is falling apart.”

Flynn’s sudden political prominence represents a departure from a 33-year military career spent largely in the shadowy realm of military intelligence and Special Operations missions. Former colleagues said they could not recall Flynn ever discussing politics while in uniform or voicing the views he has embraced since his career came to an abrupt end.

The son of a World War II and Korean War veteran, Flynn was one of nine children in a close-knit Irish family in Rhode Island. His brother Charlie is a two-star general in the Army.

Flynn’s early years in uniform coincided with the end of the Cold War, but he made his mark after the attacks of Sept. 11, 2001, as an intense officer with a string of important intelligence assignments.

Flynn, then director of the Defense Intelligence Agency, testifies on Capitol Hill in 2014. (Lauren Victoria Burke/Associated Press)

He has held senior positions in the 18th Airborne Corps, at the Joint Chiefs of Staff at the Pentagon and at U.S. Central Command, which runs U.S. military operations in the Middle East. Throughout his career, he was viewed as a charismatic and unconventional officer with a talent for mapping terrorist networks — qualities prized by superiors. But his hard-charging approach was at times considered disruptive or undisciplined.

He is best known for his integral role in the lethal machine that McChrystal assembled in Iraq to eviscerate the al-Qaeda affiliate there. Together, they perfected an approach known as “find, fix, finish” that relied on the elite Joint Special Operations Command to carry out raids and then used intelligence from captured militants and materials to identify new targets at a blistering tempo.

When McChrystal was put in charge of the war in Afghanistan, he tapped Flynn again to serve as his top intelligence officer. Flynn used that job to position himself as a gifted strategist, helping to co-write a 26-page article, “Fixing Intel,” that depicted the intelligence-gathering mission in Afghanistan as a failing endeavor that was too focused on finding targets rather than understanding cultural complexities. Some in the military praised the article as insightful, but critics considered it grandstanding at the expense of his predecessors.

Some of Flynn’s other moves angered superiors. Former U.S. officials said he was scolded after traveling to Pakistan in 2009 or early 2010 and revealing to Pakistani officials sensitive U.S. intelligence on the militant Haqqani network accused of staging attacks on American forces. U.S. officials said that the move was aimed at prodding Pakistan to crack down on the militant group, but that Flynn exposed U.S. intelligence capabilities that only helped Pakistan protect an organization it used as a proxy ally.

Flynn also came under investigation by the Pentagon because of an allegation that he had inappropriately shared highly classified intelligence with Australian and British forces. “I’m proud of that one,” Flynn said in an interview. “Accuse me of sharing intelligence in combat with our closest allies. Please!”

The inquiry delayed but did not derail Flynn’s ascent through the ranks. Always pushing for a deeper understanding of terrorist networks, Flynn persuaded Clapper in 2011 to let him form a team to reexamine the materials recovered from bin Laden’s compound in Pakistan, searching for clues overlooked by the CIA. In 2012, Obama tapped him for one of the highest positions a military intelligence officer can attain, running the Defense Intelligence Agency.

U.S. Director of National Intelligence James Clapper testifies during a House Appropriations hearing on "World Wide Threats" on Capitol Hill on Feb. 25. (Kevin Lamarque/Reuters)

Flynn arrived with a mandate for change. He began trying to reorganize the agency into regionally focused centers, station more analysts overseas and build a spying capability that could rival that of the CIA. In public remarks, he warned any employees who resisted his agenda that he would “move them or fire them.”

Almost from the outset there were concerns at the Pentagon that Flynn was struggling to execute his reform plans and that the agency was beset by turmoil. A career staff officer, Flynn had little experience running a large organization, let alone a plodding institution such as the DIA, with nearly 20,000 employees.

Former subordinates at the DIA said Flynn was so prone to dubious pronouncements that senior aides coined a term — “Flynn facts” — for assertions that seemed questionable or inaccurate.

The DIA job is ordinarily a three-year assignment. But early in Flynn’s second year, his bosses — Clapper and then-Undersecretary of Defense for Intelligence Michael G. Vickers — summoned him to a meeting at the Pentagon to tell him that he was being removed.

As the search for a replacement stalled, Flynn attempted an end-run around his superiors, appealing directly to the vice chief of staff of the Army to extend his tenure. The move infuriated Clapper, according to former officials who said the DNI warned Flynn that if he made any other attempt to circumvent the outcome he would be fired on the spot. Clapper declined to comment for this article, but several current and former officials confirmed the account.

Flynn disputed the account as well as the claim that he had shared sensitive intelligence with Pakistan, saying in an email that the claims are “all false.”

He characterizes his ouster as a political purge orchestrated by an administration unwilling to heed the warnings he was sounding about militant Islam. Asked for evidence, he said, “I just know!” adding that Clapper had once told him that the issue behind Flynn’s ouster was “not your leadership, or I would have removed you right away.”

The decision to remove Flynn was “about turbulence and a destructive climate,” said a former senior U.S. intelligence official. “I don’t think anybody in the administration was even aware of his views” on radical Islam.

Flynn’s positions have become more strident since he left DIA and are increasingly aimed at Obama. He said he is “sick and tired” of the president taking credit for approving the 2011 mission that led to the death of bin Laden. “This decision to kill bin Laden . . . so what?!” he said. “What did it really do?”

Once firmly against waterboarding and other banned interrogation measures, Flynn now appears at least willing to consider supporting Trump’s threat to reinstate those methods, saying he would be reluctant to take options off the table. Asked on Al Jazeera in May whether he would allow the military to carry out Trump’s threat to kill any families of suspected terrorists, Flynn replied, “I would have to see the circumstances of that situation.”

In February, Flynn posted a video about a Pakistani terrorist group on his Twitter account with the comment: “Fear of Muslims is RATIONAL.”

His views are difficult to reconcile with some of the prescriptions for fighting terrorism that he outlines in a recent book, “The Field of Fight: How We Can Win the Global War Against Radical Islam and Its Allies,” that he co-wrote with neoconservative analyst Michael Ledeen.

In the book, Flynn argues that the United States needs new partnerships with Middle Eastern countries and a deeper understanding of radical ideology. He said Egypt, Jordan, Qatar and Saudi Arabia should shoulder more of the responsibility for ridding themselves of terrorists, accept more Syrian refugees and deploy troops in Syria.

Asked whether his comments about Islam or Trump’s behavior — threatening to ban Muslims from entering the United States, vilifying the parents of a fallen Muslim American soldier — might alienate those potential Middle East partners, Flynn said, “I don’t see it that way. I see a lot of Muslims who actually want this conversation. They want this point to be made.”

Greg Jaffe and Julie Tate contributed to this report.