This Tennessee doctor got political. Then he sued Trump and won. Now he's out of a job.

NASHVILLE — A Tennessee doctor who became a social media sensation because of statements on President Trump, racism and Colin Kaepernick — and who later sued the president over First Amendment rights — is losing his job at Vanderbilt University Medical Center.

Eugene Gu, 32, a Vanderbilt surgery resident, said Friday that Nashville's biggest hospital is ending his five-year residency after only three years.

Technically, Vanderbilt has decided not to renew his contract with the hospital, Gu said, but he argues the effect is “no different than being fired."

“The take-home message here is that there is an unwritten rule for surgical residents and that rule is, always make your program look good and always make your hospital look good, and often that means stay silent,” Gu said. “But as an Asian-American physician, unlike a white doctor, I don’t always have the same luxury to stay silent."

Vanderbilt said in an email statement Friday that the decision not to renew Gu's contract was not a result of his criticism of Trump, his lawsuit, or his public opposition to racism. The hospital has said previously that all disciplinary actions against Gu relate to his work performance and professionalism.

More: Trump sued after blocking Twitter followers

More: Donald Trump cannot block critical Twitter users, court rules

"Regarding other allegations that Dr. Gu is making about the Medical Center, I would ask that you please consider these as allegations and nothing more," John Howser, a spokesman for the hospital, said in the email. "To date, we have not engaged in a point by point rebuttal of Dr. Gu’s many claims over the past two-plus years. At this time we will continue to maintain this stance."

Gu has become one of the most controversial figures at Vanderbilt over the past two years because of his public criticism of Trump, Republicans, gun culture and sometimes the hospital itself.

Gu is also one of seven Twitter users who sued Trump in federal court claiming the president had violated their First Amendment rights by blocking them from commenting on his tweets. The lawsuit, seen widely as a free speech debate for the social media age, ended with a ruling against the president about two weeks ago.

Trump unblocked Gu on Monday. The moment was “surreal” vindication, he said.

“When we first filed a lawsuit to defend our First Amendment rights, a big segment of the general public was almost mocking us, saying it was frivolous, and the stupidest lawsuit in the world," Gu said. "But we won — we convinced a judge that it was unconstitutional."

Eugene Gu v. Donald Trump

Trump blocked Gu last summer after the president attempted to tout his popularity on Twitter, and the doctor made fun of him for a recent blunder.

The spat began when Trump tweeted about his approval rating in a Rasmussen Poll. Gu responded with a reference to “Covfefe,” which was an apparent typo the president had tweeted about a month before. Trump's typo was left online for about six hours, bewildering the nation.

“The new Rasmussen Poll, one of the most accurate in the 2016 Election, just out with a Trump 50% Approval Rating.That's higher than O's #'s!” the president tweeted, referencing himself in third person.

Gu snarked back.

“Covfefe: The same guy who doesn't proofread his Twitter handles the nuclear button,” he tweeted.

The president then blocked Gu, but the doctor’s dramatic rise on Twitter had already started. Gu quickly found popularity for being an outspoken progressive in a profession where many colleagues avoid politics altogether.

Then, two months after his barb at the president, Gu went viral again.

Taking a knee like Kaepernick

In September, Gu tweeted a photo of himself, wearing scrubs and a lab coat, kneeling in a hospital hallway while holding a closed fist in the air.

“I’m an Asian-American doctor and today I #TakeTheKnee to right white supremacy,” Gu tweeted.

The tweet showed his support for Kaepernick, an NFL quarterback who refused to stand for the national anthem during the 2016 season to protest racial injustice. Kaepernick lost his job in the NFL but has since become an influential and divisive icon against inequality and police brutality.

Trump has railed against NFL players for kneeling during the anthem.

In the wake of Gu's viral tweet, at least two patients refused to let him treat them or their family members, he said.

Gu tweeted about that experience and he said Vanderbilt administration pressured him to delete the tweet, which he did.

Gu also spoke publicly about what he claims was a racially motivated attack on hospital grounds during the first year of his residency. Gu alleges he was attacked by a white man who shouted racial slurs in the hospital parking garage. The man followed him into the hospital before police intervened, he said. Gu said both he and the man were arrested. Charges were later dropped against both of them.

Gu regularly refers to incident as a “white supremacist attack.”

“I don’t think Vanderbilt likes people to know that racism exists in these walls,” Gu said. "But we are living an era now that is scary … especially in Nashville. Nashville is a little liberal, but its surrounded by very conservative areas, and that bleeds in to the lives of minorities here.”