WASHINGTON — Michael T. Flynn was a man seething and thwarted. In the summer of 2014, after repeatedly clashing with other Obama administration officials over his management of the Defense Intelligence Agency — and what he saw as his unheeded warnings about the rising power of Islamic militants — Mr. Flynn was fired, bringing his military career to an abrupt end.

Mr. Flynn decided that the military’s loss would be his gain: He would parlay his contacts, his disdain for conventional bureaucracy, and his intelligence career battling Al Qaeda into a lucrative business advising cybersecurity firms and other government contractors. Over the next two years he would sign on as a consultant to nearly two dozen companies, while carving out a niche as a sought-after author and speaker — and ultimately becoming a top adviser to President Trump.

“I’ve always had that entrepreneurial spirit,” Mr. Flynn said in an interview in October 2015. In the military, he added, “I learned that following the way you’re supposed to do things isn’t always the way to accomplish a task.”

But instead of lofting him into the upper ranks of Beltway bandits, where some other top soldiers have landed, his foray into consulting has become a legal and political quagmire, driven by the same disdain for boundaries that once propelled his rise in the military. His business ties are now the subject of a broad inquiry by a special counsel investigating Russian interference in the 2016 election and possible collusion with Trump associates. That investigation now includes work Mr. Flynn did for Russian clients and for a Turkish businessman with ties to that country’s president, Recep Tayyip Erdogan.