WASHINGTON — President-elect Donald J. Trump has offered the post of national security adviser to Lt. Gen. Michael T. Flynn, potentially putting a retired intelligence officer who believes Islamist militancy poses an existential threat in one of the most powerful roles in shaping military and foreign policy, according to a top official on Mr. Trump’s transition team.

General Flynn, 57, a registered Democrat, was Mr. Trump’s main national security adviser during his campaign. If he accepts Mr. Trump’s offer, as expected, he will be a critical gatekeeper for a president with little experience in military or foreign policy issues.

Mr. Trump and General Flynn both see themselves as brash outsiders who hustled their way to the big time. They both post on Twitter often about their own successes, and they have both at times crossed the line into outright Islamophobia.

They also both exhibit a loose relationship with facts: General Flynn, for instance, has said that Shariah, or Islamic law, is spreading in the United States (it is not). His dubious assertions are so common that when he ran the Defense Intelligence Agency, subordinates came up with a name for the phenomenon: They called them “Flynn facts.”