Dean Winslow, who is President Trump’s pick to lead the military healthcare system, seemed to know he was wading into treacherous political waters when he criticized U.S. gun laws as “insane” during his Senate Armed Services Committee hearing this week.

The Stanford University medical professor and close friend of Defense Secretary Jim Mattis prefaced his critique of the recent Texas church shooting by saying “I may get in trouble with other members of the committee.”

He was right. Now his nomination, which was recommended by Mattis, is now being held up by Sen. John McCain and Armed Services members who also are concerned about his advocacy in written committee testimony of “therapeutic abortion services,” another third-rail political issue.

Related: Trump Pentagon nominee on Texas shooting: It's 'insane' that civilians can buy 'assault' rifles

But it's not the first time the doctor has spoken out about his beliefs in ways that carry political and career risks.

Days after Trump announced his nomination in September, Winslow questioned the president’s rationale for a ban on transgender military service in an interview granted to a Delaware newspaper. Nominees typically avoid media contact during the confirmation process. Winslow declined an interview request by the Washington Examiner for this story.

Trump tweeted in July that the military "cannot be burdened with the tremendous medical costs” from allowing transgender troops to serve.

“Costs may be overstated,” Winslow told the News Journal. The newspaper said the response came after it pressed him to respond to the president’s claim of a financial strain.

Winslow, who served as a medical officer for 35 years in the Air National Guard, referred to a 2016 Rand Corp. study on transgender military service often cited by opponents of a ban. It found open service would increase active-duty healthcare costs by only $2.4 million to $8.4 million annually, or about one-tenth of a percent.

Mattis, who befriended Winslow at Stanford, has cast doubt on the study's findings and is now overseeing a panel of experts tasked with implementing Trump’s order to eliminate gender reassignment surgeries in the military and determine how to deal with currently serving transgender troops.

Winslow could play a role in crafting and carrying out new guidance on transgender healthcare if confirmed as assistant secretary of defense for health affairs.

“We don’t want to turn motivated people away,” he told the News Journal. "Particularly, since right now, less than 25 percent of high school students are physically qualified to join the military.”

Both Mattis and Winslow, like hundreds of thousands of troops, served together in Iraq and Afghanistan during the last decade. Mattis commanded ground forces as a Marine Corps general and later was the head of U.S. Central Command. Winslow deployed six times to support combat operations as a colonel and flight surgeon with the Air National Guard.

But the two became “close friends” at Stanford sometime after 2013, when Mattis retired from the military and became distinguished visiting fellow at the Hoover Institution think tank, which is based at the university, according to Dana White, the defense secretary’s chief spokesperson.

Winslow is the vice chair of the department of medicine at Stanford, where he specializes in infectious diseases, according to a published bio he shared with the Washington Examiner.

Following the friendship, Mattis recommended that Trump pick Winslow for the Pentagon position, White said.

Winslow told the News Journal that Mattis has “been over to our house on several occasions, and he was my boss’s boss’s boss on a few of my tours in Iraq and Afghanistan.”

It was around the time of their friendship at Stanford that Winslow became outspoken in his role as a medical doctor and challenged the local government in California where the university is located.

He was fired in 2013 from his position as chair of the department of medicine at Santa Clara Valley Medical Center after he raised concerns about how the county hospital was treating doctors and being run, according to press reports.

An online petition opposing the firing collected more than 1,200 signatures.

Winslow, whose medical career includes helping to develop two HIV antiviral drugs, sued for wrongful termination and won a $1.4 million settlement from Santa Clara County.

He and his wife used the money in 2015 to found the Eagle Fund, a charitable trust aimed at helping victims of war around the world.

“People say, ‘Oh, that was so wonderful you did that, Dean.’ But ... most officers or enlisted who would have been in my position would have done the same thing,” Winslow told Air Force Times last year.

Winslow helped bring Iraqi children and adults to the U.S. for needed surgeries and said in interviews that he developed a bond with the people there during his military deployments.

“It all worked out OK in the end, at least for me personally,” Winslow told the Mercury News newspaper in 2015 about the county lawsuit.