As President Trump and senior U.S. military leaders prepared to attend a nationally televised Army-Navy football game, the commander in chief popped a Saturday morning surprise on Twitter: He was nominating Army Gen. Mark A. Milley to become his next top military adviser.

The decision sent ripples through the Pentagon, where then-defense secretary Jim Mattis had recommended Air Force Gen. David L. Goldfein to become the next chairman of the Joint Chiefs of Staff. But Trump, feuding with Mattis, went in another direction in December 2018, months earlier than expected, according to current and former U.S. officials with knowledge of the situation who spoke on the condition of anonymity to describe internal deliberations.

“Every combatant commander and every other member of the Joint Chiefs thought there was one guy above all others, but that is not ultimately their choice,” former Air Force secretary Heather Wilson said of Mattis’s recommendation. “It’s the president’s choice, and Dave completely accepted it.”

Goldfein, 60, will step down as chief of staff of the Air Force and retire Thursday. He will be replaced by Gen. Charles “CQ” Brown, a fellow fighter pilot who has commanded Pacific Air Forces for the past two years, during an Air Force ceremony at Joint Base Andrews in Maryland. He will become the nation’s first Black service chief.

Goldfein, who was once shot down over Serbia and rescued, leaves a legacy that includes overseeing the service during the air war against the Islamic State, carving a new Space Force from his service and speaking out on the issue of racial inequality.

The general has deflected questions about being bypassed for the chairmanship and was effusive in an interview in his praise of Milley, who replaced Marine Gen. Joseph F. Dunford Jr. as chairman last September.

“I think he’s doing a magnificent job in a very tough environment,” Goldfein said, giving Milley high marks for his communication with other chiefs. “I’m proud of him, and I’m proud to call him my chairman, and I think the president got it exactly right.”

Goldfein, like most other military officers, adheres to the Pentagon’s long-standing tradition of remaining nonpartisan while in uniform. But he acknowledged it took him a while to embrace the Space Force, which he and other officials opposed before Trump ordered its creation.

The effort to establish a space service came up in 2017 after House lawmakers proposed the establishment of the Space Corps, an organization that would stand alone as a separate branch of service.

Mattis, Goldfein and Wilson all said doing so was unnecessary. But Trump in 2018 directed the Pentagon to begin establishing the service with its current name.

Goldfein said he had worked as chief to be “relentless” about integrating space into joint Air Force operations, and was concerned that establishing a separate space service could run counter to that.

He recalled meeting with Air Force officers studying space strategy at Maxwell Air Force Base in Alabama. After he shared his concerns, he said, several disagreed, and he asked how many thought a separate space service made sense. All of the officers put their hands up, he said.

“That was a turning point for me because I realized, “Okay, these are my airmen, and they’re telling me something I’ve got to pay attention to,” Goldfein said.

Wilson, asked about Goldfein’s tenure, called him a friend and “remarkable human.” But she remains a Space Force skeptic, an issue that created friction within the Trump administration before she resigned and departed for academia last year.

Wilson said she is worried space capabilities ultimately could be hurt.

“When it’s a no longer a new, shiny thing, will it still be able to hold its own in a Pentagon bureaucratic fight as a service that is smaller than the Coast Guard?” she said. “It bothers me when people are always finding the joke in it. No military service should be made fun of, and I think you can probably see that. It’s hard to maintain long-term.”

Deborah James, who served as Air Force secretary in the Obama administration, said that when Goldfein took over, he hit the ground running with a clear agenda. He will be remembered for “multi-domain command and control,” in which conventional military operations are fully integrated with operations in space and cyberspace through high-speed networks, she said.

There are still skeptics of the concept, especially the Advanced Battle Management System, the Air Force’s effort to share data among service members in combat through secure, cloud-based computing. The Government Accountability Office raised concerns in April that the service does not yet have a complete plan for the system.

But some $950 million in contracts have been signed, and testing is underway.

“I think he’s got a lot converts, and I think he has won a lot of people over,” James said. “He certainly has built tremendous support among his fellow chiefs. There’s money and budget behind the ideas now, and he has brought the issue to the forefront.”

David Deptula, a retired Air Force lieutenant general, said Goldfein effectively advocated for his service, but also showed a willingness to make trade-offs with the rest of the military. He cited Goldfein’s proposal to retire some older aircraft to focus on a new generation of weapons.

Deptula also said Goldfein “stuck his neck out” on sensitive issues, including persistent problems with suicides and racial inequality.

After the death of George Floyd, a Black man whose death in Minneapolis police custody prompted national outrage, Goldfein became the first service chief to speak out, writing in a memo that Floyd’s death was “a national tragedy” and commanders needed to confront racism in their own ranks.

“To him, it was doing what was the right thing,” Deptula said. “Someone with a fundamental ethos, and level of integrity, and confidence in their perspective isn’t afraid of getting engaged or speaking out.”