An argument in February between White House chief of staff John F. Kelly and Corey Lewandowski, an informal adviser to President Donald Trump, turned into a physical altercation that required Secret Service intervention just outside the Oval Office, according to a half-dozen people familiar with the events.

The episode, details of which have not been previously reported, is the latest illustration of the often chaotic atmosphere Trump is willing to tolerate in the White House as well as a reflection of the degree to which Kelly’s temper can be provoked.

The near brawl — during which Kelly grabbed Lewandowski by the collar and tried to have him ejected from the West Wing — came at a time when the chief of staff was facing uncertainty about how long Trump would keep him in his job. A guessing game over his departure has colored his tenure since.

Kelly, a retired four-star Marine Corps general, was widely hailed as the lone grown-up who could corral a staff full of bombastic and competing personalities when he was appointed in summer 2017. But Kelly has shown little inclination to curb his own instinct for confrontation, from scuffling with a Chinese official during a visit to Beijing in 2017 to last week’s profanity-laced shouting match with national security adviser John R. Bolton after a meeting with the president.

White House officials declined to comment for this article. Lewandowski did not respond to multiple requests for comment.

But the altercation Feb. 21 was among the ugliest known to have taken place in a West Wing that has been characterized by constant drama and heated skirmishes — all forms of behavior that the president has long tolerated among his aides.

While Kelly’s initial appointment was widely seen as a move to restore a sense of order, he has instead been at the center of a succession of conflicts, from his contradictory statements about former White House staff secretary Rob Porter, who left after previous allegations of domestic violence were made public, to his heated interactions with other aides. Anthony Scaramucci, who has written a book about being Trump’s communications director for 11 days until Kelly fired him after the release of a recording of his own profanity-laced call with a reporter, said on NBC’s “Meet the Press” on Sunday that Kelly had “hurt the morale inside the place.”

“And he’s hurt the president. And he has hissy fits,” Scaramucci said, adding that “he’s demonstrating his personality now the way he really is.”

Kelly’s defenders argue that he has been effective at ridding the White House of problematic personalities, such as Omarosa Manigault Newman, and that he has put in place a degree of order that did not exist before his arrival, despite the challenges of the work environment that Trump creates. And a person who witnessed the exchange between Kelly and Bolton last week insisted there was never a shouting match as described in many accounts.

Former Secretary of Defense Leon Panetta defended Kelly, who served as his senior military assistant when he was at the Pentagon, as a “fine person” and a “good Marine” who would “walk off a cliff” for people who earned his loyalty.

But, Panetta said, “there’s no question that the level of frustration must be rising if he’s getting into shouting matches and starting to really take on other people.”

“That doesn’t happen unless he is totally frustrated,” Panetta continued.

On the day Kelly grabbed Lewandowski, families of the shooting victims from Marjory Stoneman Douglas High School in Parkland, Florida, were streaming into the White House for an event with the president in the East Room. Trump had both men in his office, according to those briefed on the event. Lewandowski, the president’s first campaign manager, was there for a previously scheduled appointment.

Kelly criticized Lewandowski to Trump for making so much money off the president in the form of his contract with the super PAC supporting the president’s re-election. Kelly also expressed his anger that Lewandowski had been criticizing him on television for his handling of the security clearance controversy related to Porter.

At some point, Trump took a phone call, and both men left the room, those briefed on the episode said.

As Kelly walked toward a hallway leading back to his office, he called to someone to remove Lewandowski from the building. The two then began arguing, with Lewandowski speaking loudly. Kelly grabbed Lewandowski by his collar, trying to push him against a wall, according to a person with direct knowledge of the episode.

Lewandowski did not get physical in response, according to multiple people familiar with the episode. But Secret Service agents were called in. Ultimately, the two men agreed to move on, those briefed on the episode said.

Still, people in the West Wing who learned at the time what had happened were stunned.

In the months since the altercation, Lewandowski has traveled frequently with Trump aboard Air Force One to his political rallies and has continued to meet frequently with the president in the White House, though West Wing aides now try to make sure he steers clear of Kelly’s corner of the West Wing. He is also writing a book, “Trump’s Enemies: How the Deep State Is Undermining the Presidency,” which is scheduled to be published in the weeks after the midterm election and which some in Trump’s circle fear will take swipes at some of his aides.

On the other hand, Kelly, who is called “the general” or “the chief” by his allies inside the West Wing, is widely seen as a diminished presence among the president’s advisers. Though Kelly has repeatedly said he expresses his honest opinions to Trump, he has shown little inclination or ability to curb some of the president’s impulses.

He is not the first chief of staff to struggle with his image inside and outside the White House: Administration observers compare Kelly to Donald T. Regan, President Ronald Reagan’s former chief of staff, who amassed power in the West Wing only to squander it in clashes with other advisers and the president’s wife.

With his legacy in mind, Kelly tends carefully to his press coverage, and keeps his eye on those he considers to be friendly to him in print and on the broader White House staff, according to multiple current and former aides. The president, who publicly maintains that his West Wing runs like a well-oiled machine, recently invited a reporter — along with his vice president, secretary of state and Kelly — into the Oval Office to show just how much faith he has in his chief of staff.

“There is, to the best of my knowledge, no chaos in this building,” Kelly said during that interview. “We’ve gotten rid of a few bad actors, but everyone works very, very well together.”

In July, Kelly told aides that Trump had asked him to stay on in his role until 2020, but reports of his conflicts with other staff members have continually raised questions about how long he will last. Even Trump has privately indicated to people that he was skeptical that Kelly would remain that long.

“I think John does this out of loyalty to the country,” Panetta said, “and the hope that, somehow, for all of the difficulty that he’s confronting, that somehow he’s serving a purpose.” The president, for his part, has shown a certain reverence for men willing to engage in physical scuffles. In fall 2017, when Kelly was newly in his role, his willingness to engage angrily in meetings with then-national security adviser Lt. Gen. H.R. McMaster thrilled Trump. The president, who did not like McMaster, gleefully told people about the skirmishes between the two men for weeks, saying it showed how tough Kelly was, a person familiar with the discussions said.

And The Wall Street Journal recently reported that Kelly got into a physical altercation with a Chinese official trying to gain access to the nuclear football, which is used to authorize a nuclear attack, during Trump’s trip there last year.

But recently, Kelly has gone from enjoying Trump’s public praise — “He has been a true star of my Administration,” the president said of Kelly in summer 2017 — to someone often sidelined by a president who believes he is his own best chief of staff.

Kelly, meanwhile, has chosen to stay in the role despite Trump’s clear interest in keeping Lewandowski around in some fashion.

“I think Trump has decided it’s really a bad marriage,” said Chris Whipple, author of “The Gatekeepers,” a history of White House chiefs of staff, “that he has decided to muddle through.”