WASHINGTON (Reuters) - Longstanding friction between U.S. President Donald Trump and two top aides, the National Security Adviser and the Chief of Staff, has grown to a point that either or both might quit soon, four senior administration officials said.

Both H.R. McMaster and John Kelly are military men considered by U.S. political observers as moderating influences on the president by imposing a routine on the White House. They have also convinced Trump of the importance of international alliances, particularly NATO, which he has criticized as not equally sharing its burdens with the United States.

However, all the officials were quick to add that the tensions could blow over, at least for now, as have previous episodes of discord between the president and other top officials who have fallen out of favor, including Secretary of State Rex Tillerson and Attorney General Jeff Sessions.

Asked about sources saying that either National Security Adviser McMaster or Chief of Staff Kelly, or both, might be leaving, White House spokesman Raj Shah on Thursday did not address the possibility. He said, “the president has full confidence in each member of the team.” Press secretary Sarah Sanders said on Tuesday that Trump “still has confidence in General McMaster.”

Neither Kelly nor McMaster responded to requests for comment on whether they would remain in the administration.

Trump swatted McMaster in a Twitter post after his comments at a European conference last weekend that he was certain Russia meddled in the 2016 U.S. election campaign, which Trump has been reluctant to acknowledge.

Kelly and McMaster have chafed at Trump’s treatment of them in public and in private, which both at times have considered insulting, said all four officials, speaking on condition of anonymity.

FILE PHOTO - U.S. National Security Adviser H.R. McMaster talks at the Munich Security Conference in Munich, Germany, February 17, 2018. REUTERS/Ralph Orlowski

The current and most potent irritant, they said, is Kelly’s effort, supported by McMaster, to prevent administration officials who have been unable to obtain permanent high-level security clearances from having access to the government’s most closely held secrets.

Under pressure to act last week, Kelly strengthened the security clearance process in response to a scandal involving Rob Porter, a former official accused of domestic abuse by two ex-wives. Staffers whose interim clearances have been pending since June would have them revoked on Friday.

That would bar Trump’s son-in-law and adviser Jared Kushner from reading the president’s daily intelligence brief, which often contains information on covert operations and intelligence collected from spy satellites, spies, and close U.S. allies.

“There have been running battles between Trump and his generals,” said one of the officials, speaking on the condition of anonymity. Kelly is a retired Marine general and McMaster an Army lieutenant general.

“But the clearance business is personal, and if Trump sets special rules for family members, I’m not sure if Kelly and McMaster would salute,” the official said.

White House officials were working to find a compromise that would allow Kushner to continue his work as a senior adviser to Trump, another source familiar with the situation said, also speaking on the condition of anonymity to discuss internal White House matters.

Under current law and regulation, the president has authority to grant any level of clearance to anyone he chooses, but officials wanted to avoid that option, this official said. There was no sense that Kushner would be leaving his job.

Kelly declined to comment on anybody’s specific security clearance. He said in a statement that he had told Kushner days ago that he had “full confidence in his ability to continue performing his duties in his foreign policy portfolio.”

Kelly said those duties include overseeing the Israeli-Palestinian peace effort and serving as an integral part of the U.S. relationship with Mexico.

McMaster’s support for Kelly on the security clearance issue is only his latest difference with Trump. Officials in the Defense Department said there have been discussions about him returning to the Army, possibly as head of the Forces Command at Fort Bragg, in North Carolina. McMaster, 55, previously served as deputy commander there.Although he has been supportive of Trump on many issues, including threatening North Korea with military action, McMaster has taken a harder stance on Russia than his boss.

After U.S. Special Counsel Robert Mueller charged 13 Russians, a Russian propaganda arm and two other firms on Feb. 16 with tampering in the election to boost Trump, McMaster said the evidence of Moscow’s meddling was “incontrovertible.”

Trump publicly chastised McMaster in a Twitter post, saying McMaster “forgot to say that the results of the 2016 election were not impacted by the Russians.”