WASHINGTON — President Donald Trump has become increasingly frustrated with his advisers tasked with crafting a new U.S. strategy in Afghanistan and recently suggested firing the war's top military commander during a tense meeting at the White House, according to senior administration officials.

During the July 19 meeting, Trump repeatedly suggested that Defense Secretary James Mattis and Chairman of the Joint Chiefs of Staff Gen. Joseph Dunford replace Gen. John Nicholson, the commander of U.S. forces in Afghanistan, because he is not winning the war, the officials said. Trump has not met Nicholson, and the Pentagon has been considering extending his time in Afghanistan.

Over nearly two hours in the situation room, according to the officials, Trump complained about NATO allies, inquired about the United States getting a piece of Afghan’s mineral wealth and repeatedly said the top U.S. general there should be fired. He also startled the room with a story that seemed to compare their advice to that of a paid consultant who cost a tony New York restaurateur profits by offering bad advice.

Trump is the third president to grapple with the war in Afghanistan. On Wednesday, two American troops were killed in Afghanistan when a convoy they were in came under attack. The Taliban claimed responsibility for the attack.

Trump's national security team has been trying for months to come up with a new strategy he can approve. Those advisers are set to meet again to discuss the issue on Thursday at the White House. The president is not currently scheduled to attend the meeting, though one official said that could change.

Former presidents Barack Obama and George W. Bush went through multiple strategies over the course of their presidencies to try to stabilize Afghanistan. What set Trump apart in the July meeting was his open questioning of the quality of the advice he was receiving.

President Donald Trump is introduced by Defense Secretary James Mattis during the commissioning ceremony of the aircraft carrier USS Gerald R. Ford at Naval Station Norfolk. Jonathan Ernst / Reuters

During the meeting, Trump criticized his military advisers seated around the table in the White House Situation Room for what he said was a losing U.S. position in the war, according to the senior administration officials. At one point the president directed his frustration at Mattis, saying Trump had given the military authority months ago to make advances in Afghanistan and yet the U.S. was continuing to lose ground, the officials said.

Related: Pentagon Weighs More Aggressive Role in Afghanistan

"We aren't winning," Trump complained, according to these officials. "We are losing."

One official said Trump pointed to maps showing the Taliban gaining ground, and that Mattis responded to the president by saying the U.S. is losing because it doesn't have the strategy it needs.

The White House declined to comment on internal deliberations.

"The president's national security team is developing a comprehensive, integrated strategy for South Asia that utilizes all aspects of our national power to address this complex region," said Michael Anton, spokesman for the National Security Council. "That strategy has been worked carefully in the interagency process and while no decision has been made the president's team continues to develop options for him that address threats and opportunities to America arising from this vital region."

Told that Trump was considering firing Gen. Nicholson, Sen. Lindsey Graham, R-S.C., a member of the Senate Armed Services Committee, said, "I can't think of a good reason to fire the general. I think he's done an admirable job."

Joint Chiefs Chairman Gen. Joseph Dunford testifies on Capitol Hill on March 22. Manuel Balce Ceneta / AP File

"If the president doesn't listen to the generals, like Gen. Nicholson and he goes down the road that President Obama went, Afghanistan is going to collapse," Graham said. "Here's my advice to the president — listen to people like Gen. Nicholson and McMaster and others who have been in the fight."

Trump Compares Afghanistan to a Famous New York Restaurant

The president's advisers went into the mid-July meeting hoping he would sign off on an Afghanistan strategy after months of delays, officials said. One official said the president's team has coalesced around a strategy, though it had presented him with other options as well such as complete withdrawal.

Trump, however, appeared to have been significantly influenced by a meeting he'd recently had with a group of veterans of the Afghanistan war, and he was unhappy with the options presented to him.

Trump vented to his national security team that the veterans told him forces from the North Atlantic Treaty Organization have not been helpful, and he lamented that China is making money off of Afghanistan's estimated $1 trillion in rare minerals while American troops are fighting the war, officials said. Trump expressed frustration that his advisers tasked with figuring out how the U.S. can help American businesses get rights to those minerals were moving too slowly, one official said.

China purchased mineral rights in Afghanistan a decade ago, an investment the U.S. supported at the time. Beijing has since had teams mining copper outside of Kabul.

The focus on the minerals was reminiscent of Trump's comments early into his presidency when he lamented that the U.S. didn't take Iraq's oil when the majority of forces departed the country in 2011.

To underscore his view that the veterans who fought in the war may be better positioned to advise him on an Afghanistan strategy, Trump compared the policy review process to the renovation of a famed New York restaurant in the 1980s, officials said.

Trump told his advisers that the restaurant, Manhattan's elite '21' Club, had shut its doors for a year and hired an expensive consultant to craft a plan for a renovation. After a year, Trump said, the consultant's only suggestion was that the restaurant needed a bigger kitchen.

"We aren't winning. ... We are losing."

Officials said Trump kept stressing the idea that lousy advice cost the owner a year of lost business and that talking to the restaurant's waiters instead might have yielded a better result. He also said the tendency is to assume if someone isn't a three-star general he doesn't know what he's talking about, and that in his own experience in business talking to low-ranking workers has gotten him better outcomes.

The '21' Club, which has been one of Trump's favorite New York spots, closed for two months in 1987 while it underwent a full renovation and reopened to great fanfare.

U.S. troops walk outside their base in Uruzgan province, Afghanistan July 7, 2017. Omar Sobhani / Reuters

One senior administration official said the president mentioned the restaurant in an attempt to convey to his advisers that sometimes the best advice comes from those working day-to-day in a place, rather than those who are farther removed.

"The clear message if you heard the story was: high-priced consultants or high-priced anybody, expensive supposedly-big-brained people, but who are physically far from the source of the problem, often give you much worse advice than the supposedly low-ranking guys who are right there," the official said.

Mattis Upset After Trump Meeting

Trump left the national security meeting without making a decision on a strategy. His advisers were stunned, administration officials and others briefed on the meeting said.

Two Pentagon officials close to Mattis said he returned from the White House that morning visibly upset. Mattis often takes a walk when grappling with an issue. That afternoon, the walk took longer than usual, the officials said.

Among those at the meeting were Trump's senior White House advisers including Steve Bannon, Jared Kushner, national security adviser H.R. McMaster, and then chief-of-staff Reince Priebus, plus Mattis, Dunford, Vice President Pence and Secretary of State Rex Tillerson.

At one point, Dunford offered to set up a meeting for Trump with Gen. Nicholson in the hopes that personal interaction may soothe Trump's concerns about his leadership.

Mattis also defended Gen. Nicholson, an official said, adding that the conversation about the commander ended inconclusively.

In an interview with MSNBC on Wednesday, McMaster praised Nicholson.

"I've known him for many years," McMaster said. "I can't imagine a more capable commander in any, on any mission." Asked whether the president had confidence in Nicholson, McMaster said "absolutely."

But a defense official confirmed that discussions are underway at the Pentagon regarding Nicholson's future in Afghanistan.

Pentagon Chief Spokesperson Dana White told NBC News that Mattis “has confidence in Gen. Nicholson’s leadership.”

General John Nicholson, the Commander of US Forces Afghanistan and NATO's Resolute Support Mission, speaks during an opening ceremony of "Invictus Games" at the Resolute Support Headquarter, in Kabul, Afghanistan on May 13 , 2017. Massoud Hossaini / AP file

Retired Adm. James Stavridis, a former head of NATO and an NBC News analyst, suggested the delay in finalizing a strategy has hurt U.S. efforts in the war.

"The situation in Afghanistan is not improving, but I think it's hardly irretrievable at this point, and what the president needs to be doing is deciding on the strategy," Admiral Stavridis said.

"What is hurting the process at the moment is this back and forth about do we stay or do we go, how many troops," he added. "Any commander is going to be incredibly handicapped in an environment like that. So I think the fundamental problem here is lack of decisiveness in Washington, specifically in the White House."

During the presidential campaign, Trump often talked about knowing more than U.S. military generals. Last September, he suggested he would probably have different generals from those who served under former President Barack Obama.

Related: Afghan Violence: Attack Hits Convoy, Kills 2 U.S. Service Members

Retired four-star Gen. Barry McCaffrey advised against shaping a strategy around advice from troops serving on the ground.

"One of the last things you necessarily want to do is form policy advice based on what the current combatants think about something in a war zone," said Gen. McCaffrey, an MSNBC military analyst. "They're qualified totally to talk about tactics and things like that and what they're seeing, but the president's job is to formulate strategy and policy not to do tactical decisions."

He also said acquiring mineral rights in Afghanistan is complicated and potentially costly because it would require the type of security the U.S. has been unable to achieve, as well as a workforce and access to a port to ship the materials.

Nicholson has called the war a "stalemate" and said he needs a "few thousand" additional troops. "Offensive capability is what will break the stalemate in Afghanistan," he said in February during testimony before the Senate Armed Services Committee.

His comments angered White House officials who thought they boxed in the president before he had made any decisions, according to Pentagon officials.

In a recent NBC News/Wall Street Journal poll of key counties where Trump had broad support in the November election, 46 percent of respondents supported sending more troops to Afghanistan while 36 percent opposed.

Related: Watchdog: Pentagon Should Declassify Report on Afghan Military Sex Abuse

Heading into its 16th year, the war in Afghanistan is the longest war in U.S. history.

A decision on an Afghanistan strategy was expected more than two months ago, but it has been delayed as the president remains unsatisfied with the options. Last month he gave Mattis authority to set troop levels in Afghanistan, but Mattis has been unable to do so absent a presidential strategy. Trump also gave his military commanders broad authority to make key decisions. The move resulted in the U.S. dropping its largest non-nuclear weapon in Afghanistan several months ago.

The U.S. currently has about 8,400 troops in Afghanistan. Some of Trump's advisers are advocating for a very limited U.S. role in the war, while others have recommended several thousand additional troops. Officials said it's unclear when the president will sign off on a new strategy.