SAN DIEGO — President Trump ventured into what his team regards as enemy territory on Tuesday, and it was not a peace mission.
In his first visit as president to California, the blue bastion of liberal resistance, Mr. Trump unloaded on Gov. Jerry Brown, a Democrat, and called on Congress to punish jurisdictions in the state that do not cooperate with federal immigration authorities.
“Governor Brown does a very poor job running California,” Mr. Trump said during a visit to the Mexican border, where he inspected prototypes of the wall he wants to build. “They have the highest taxes in the United States. The place is totally out of control. You have ‘sanctuary cities’ where you have criminals living in the sanctuary cities.”
His broadside escalated a feud between the United States’ chief executive and the most populous state in his country, an argument rooted in ideology, culture, race and sensibility. Mr. Trump’s administration has filed a lawsuit against California over immigration policy, while the state’s attorney general has filed dozens of lawsuits against the Trump administration on a variety of fronts.
Mr. Brown said last week that Mr. Trump was waging war against the state, and Mr. Trump did nothing on Tuesday to disabuse that notion.
“California sanctuary policies put the entire nation at risk,” the president said, speaking in front of a homeland security mobile command center not far from eight proposed wall sections towering over his delegation. “They’re the best friend of the criminal.”
Mr. Brown used the president’s favorite medium to fire back. “Thanks for the shout-out, @realDonaldTrump,” the governor wrote on Twitter. “But bridges are still better than walls. And California remains the 6th largest economy in the world and the most prosperous state in America. #Facts.”
Shepherded around in his armored cars and Marine helicopters, Mr. Trump was largely insulated from the dissenters in a state that he lost by four million votes in 2016 and where just 30 percent approve of his performance today. But his trip generated strong feelings that were on display in his wake as he visited San Diego before heading to Los Angeles for a fund-raiser.
A few miles of freeway to the west from the border zone he visited, Mr. Trump’s opponents gathered in the parking lot of a hilltop church overlooking Mexico. His supporters assembled at an industrial park off in the distance.
The separation was by design: Organizers from each side said they wanted to stay apart and avoid clashes. As much as each place represented opposing views of a polarized United States, many of the same emotions were on display — anger, resentment, sadness.
Mr. Trump’s supporters were angry at immigrants, his opponents at a “militarized” border force and the president himself. On each side were woeful personal stories.
Among Trump supporters, the focus was on loved ones lost to killings or drunken driving crashes carried out by undocumented immigrants. Among the opposition, the talk centered on families separated or desperate migrants dying trying to reach the United States.
It was a day for the bullhorn and the podium, but not for mass protests, as immigrant rights activists, faith-based groups, union organizers and clergymen used the visit to hone their messages before the midterm elections.
At the anti-Trump church gathering, Representative Juan C. Vargas, a Democrat whose district includes part of San Diego, delivered a passionate rebuke of the president. “If we didn’t have immigrants, he wouldn’t have wives!” he said. He added, “We have to resist and we have to let him know that California doesn’t welcome him.”
Neal José Wilkinson, a pastor in San Diego, made a plea for civil disobedience. Saying that Jesus was killed because he broke the rules, Mr. Wilkinson declared, “There’s a higher authority then you Donald Trump!”
There were softer appeals, as well. “I ask you to keep building bridges of love, of kindness to other people,” said José Castillo, the pastor of Our Lady of Mt. Carmel, the Catholic church where the rally was held.
Mr. Trump’s welcome committee of a few hundred people, many dressed in the flag, gathered for what was part pep rally and part celebration of what they viewed as the fulfillment of a campaign promise: the construction of a wall to keep undocumented Mexican immigrants away. To a scratchy rendition of Lee Greenwood’s “God Bless the U.S.A.,” mixed with clips of Mr. Trump’s acceptance speech at the 2016 Republican National Convention, supporters cast themselves as “deplorables” and enthusiastic gun owners, and hoped for a glimpse of the president’s motorcade.
“He said secure the borders, build the wall, everything,” said Julie Horn, explaining her support. Her husband, Scott, a retired construction worker, echoed her views. “I think he’s done great,” he said. As Trump supporters in California, they said they were living in the state only to be close to their grandchildren.
“You don’t put a Trump sticker on your car,” Ms. Horn said. “Your car will get smashed.”
Not all of the faces at the rally were white. Kathy Robinson, who is African-American and from Burbank, and who works as a wedding photographer and Uber driver, voted in 2016 for Hillary Clinton. But after the election, she said she regretted that, and had come to view undocumented immigrants as a menace who take jobs away from American citizens. “Trump is not racist,” she said. “He’s just against illegal immigrants. He loves black people.”
Later in the day, Mr. Trump addressed a hangar full of enthusiastic military service members at Marine Corps Air Station Miramar before attending a fund-raiser expected to raise $5 million at the home of Edward Glazer, a chairman of the Tampa Bay Buccaneers.
Mr. Trump has stayed away from California until now, realizing that the state is beyond his reach in 2020 if he runs for re-election, as he says he will. But he noted that he owns property in the state. “The taxes are way, way out of whack,” Mr. Trump said, “and people are going to start to move pretty soon.”
At the border, Mr. Trump inspected eight wall prototypes, all of them looming over him. The border section he visited is currently guarded by a wire fence and sheet metal barrier, which local border patrol agents said have cut down on crossings since they were first put up. Mr. Trump argued that they need to be replaced by something more permanent and impenetrable. He expressed a preference for the models that have slats allowing border patrol officers to see through them.
As Mexicans watched from across the barrier, Mr. Trump described an epidemic of drugs and human traffickers that he has vowed to stop. He argued that building a wall would cost less than what he said was the price of social ills created by illegal immigration.
“We need safety,” Mr. Trump said. “We need security at the border and we’re getting it like we’ve never had it before. But we want to make it perfecto.”