LOS ANGELES — Xavier Becerra played a fair amount of poker in his younger days. So, when the California attorney general thinks today about his most frequent adversary, President Donald Trump, he recalls players who came to the table with massive stacks of chips.

The high rollers could be intimidating.

“You know this guy can bet big anytime he wants,” Becerra said recently in Sacramento. “But, more often than not, those guys with those massive trays of chips would lose, because there is always someone at the table who knows how to play those guys. And I am thinking that is the way it is with Donald Trump.”

Sworn in as the state of California’s top lawyer four days after Trump’s inauguration, the 12-term Democratic congressman from Los Angeles has become the president’s legal nemesis. His California Department of Justice has gone to court 28 times against the Trump administration, winning most of the preliminary hands in what promises to be a protracted, high-stakes game.

Related: Trump’s Justice Department sues California over immigration enforcement

The disputes involve a variety of topics: the deportation of undocumented immigrants, the enforcement of auto fuel-efficiency standards, the proposed expansion of oil drilling off the California coast, and the construction of Trump’s cherished border wall, prototypes of which the president inspected Tuesday on his first visit to California since taking office.

Trump lost the state by more than 4 million votes in 2016, and Becerra joined in the wide disdain heaped on the visitor, chiding Trump for building “medieval walls [that] might keep you safe from knights on horses,” but do nothing to protect modern-day Americans.

To contrast himself with the president, Becerra stood in front of an array of assault rifles Tuesday at a news conference in Los Angeles, lauding a California program that has seized more than 13,000 weapons over five years from felons and others outlawed from possessing them. He compared that with Trump’s quickly abandoned pledge to enhance at least some gun controls following last month’s shooting at a Florida high school. ”While in D.C. they talk,” Becerra said, “in California, we act.”

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

In the 60-year-old attorney general, Trump, 71, could not have drawn a more apt nemesis: The chief executive born to power and luxury squares off against the son of blue-collar Mexican immigrants. Where Trump is unbridled, Becerra reins his words tightly. Where Trump’s personal life has been tabloid fodder, Becerra’s family life would be at home in a church circular. Trump has trouble waiting for colleagues, while Becerra often defers, particularly to California’s sometimes bombastic resistor-in-chief, Gov. Jerry Brown.

Brown last week lashed out at the “circus” that U.S. Attorney General Jeff Sessions created coming to California, from a White House “full of liars,” to challenge state laws the Trump administration says prevent the capture of undocumented immigrants. Becerra stood a few paces away, smiling wanly at Brown, like an amused nephew watching over his rambunctious uncle.

Legal experts say they expect the struggle between the Trump administration and leaders in California and other liberal states to be protracted, with neither side having a clear advantage. They see no small irony in the fact that the Golden State and others are now invoking states’ rights and the 10th Amendment to rein in what they see as an overreaching federal government — co-opting arguments that conservatives used over many decades to block school desegregation, same-sex marriage and other liberal imperatives.

Said Erwin Chemerinsky, dean of the law school at the University of California, Berkeley, “In one sense, this is federalism turned on its head from what we have seen through much of our history.”

Becerra is as surprised as anyone to have emerged as Trump’s chief interlocutor. The Sacramento native graduated from Stanford and Stanford Law School and worked his way from the California Assembly to a seat in Congress, representing the heart of Los Angeles. He’d climbed to the No. 4 leadership spot among House Democrats, high enough up that he was mentioned as a long-shot pick to be Hillary Clinton’s running mate in 2016 and a likely appointee in a Clinton Cabinet.

But Trump’s victory blocked any obvious path to advancement for Becerra. He was mulling a bid to become the top Democrat on the powerful House Ways and Means Committee when a call came from Brown, whom he barely knew. Brown wondered if Becerra would consider becoming attorney general, to replace Kamala Harris, who had won a seat in the U.S. Senate. “It was unexpected,” Becerra recently recalled, before a long pause. “Very unexpected,” then another pause. “Really unexpected.”

Xavier Becerra, then a U.S. congressman, speaks during the Democratic National Convention at Wells Fargo Center on July 28, 2016, in Philadelphia. Nicholas Kamm / AFP - Getty Images

Becerra today has returned to the state capital where he grew up, to a home right next door to his parents’. His father was born in the U.S. but spent his early years in Mexico, while his mother was born in Jalisco State. His father picked fruit, built homes and paved roads, while his mother found clerical work. The attorney general tells how his father recalled not being able to enter restaurants with signs saying “No dogs or Mexicans allowed.” He and his three sisters and their parents shared a 750-square-foot home.

In Becerra’s view, California is a thriving place that doesn’t need, or want, Trump’s intervention. He likes to talk about the size of the state’s economy (sixth largest in the world) and how California has taken the lead on promoting equal rights for ethnic minorities and progressive policies like gun control.

“The thread that runs through everything I have done is to try to protect my state” and its leadership role, Becerra said. “These lawsuits are just because we want to keep that going.”

Lawsuits initiated, or joined, by Becerra’s office have temporarily preserved the Obama-era program, Deferred Action for Childhood Arrivals, that protects from deportation immigrants brought to the U.S. as young children; blocked a Trump administration effort to bar transgender individuals from serving in the military; thwarted rules that would allow health care providers to stop providing birth control on moral or religious grounds; and forced the administration to enforce rules limiting releases of methane from oil and gas drilling sites.

On Monday, California and 13 other states won another victory when a federal judge in Oakland ordered the Environmental Protection Agency to report on whether the smoggiest regions in the country were meeting ozone safety standards. That’s a task the agency had failed to complete under the guidance of EPA Administrator Scott Pruitt.

Xavier Becerra discusses the need for bail reform on Feb. 20 in Sacramento. Rich Pedroncelli / AP

The Trump White House did not respond to a request for comment about Becerra’s actions. The administration’s most aggressive counterattack came in the form of a lawsuit last week against the state, Brown and Becerra, alleging that they were illegally trying to usurp federal authority over immigration. Among the state laws challenged was the California Values Act, which limits how much state and local officials can share about criminals and suspects unless they have been convicted of serious crimes.

Becerra said his office will zealously defend the state’s position that it is not blocking the federal government, but merely refusing to be its agent on policies Californians don’t back. When he helps prevent California cops from becoming “deportation agents,” Becerra believes that he is protecting hardworking people like his parents.

“You are given a chance in this country,” he said. “The thing about America is it redeems itself.”