SAN DIEGO — Making his first trip to California since taking office, President Trump on Tuesday showed off prototypes for his long-promised border wall, strongly condemned jurisdictions that offer “sanctuary” to undocumented immigrants — and accused the state’s governor of doing “a terrible job.”

The visit, which drew protesters on both sides of the U.S.-Mexico border, came at a time of escalating acrimony between Trump and Democratic leaders of the nation’s most populous state, who have sought through legislation and lawsuits to counter Trump on immigration and other policies.

Even against that backdrop, Trump’s swipe at Gov. Jerry Brown (D) was remarkable coming from a sitting president. As Trump toured the site of eight prototypes of the border wall, he told onlookers that Brown “does a very poor job of running California.”

“They have the highest taxes in the United States,” Trump said. “The place is totally out of control. You have sanctuary cities where you have criminals living in the sanctuary cities.”

The president also noted that he owns property in the state — a home in Beverly Hills and a golf club in Rancho Palos Verdes — and predicted that people would start to move out of California because of taxes that are “way, way out of whack.”

Brown responded on Twitter, thanking Trump for the “shout-out.”

“California remains the 6th largest economy in the world and the most prosperous state in America,” Brown wrote, adding: “#Facts.”

Trump’s trip included an address to military personnel here at Marine Corps Air Station Miramar, where he was well-received as he touted planned pay raises and new investments in helicopters and other equipment. Trump also floated the idea of creating a new branch of the military to fight in space.

The president later attended a fundraiser in the Los Angeles area to benefit the Republican National Committee. A few hundred people reportedly turned out to protest near the Beverly Hills residence where Trump gathered with donors.

The border-wall prototypes Trump visited are on display in a dusty lot near the border. The 30-foot-tall barriers use varying configurations of steel, concrete and even spikes to create ramparts far more formidable than almost anything in place along the 2,000-mile border with Mexico.

The Trump administration is seeking $18 billion for wall construction over the next 10 years, an amount that would pay for roughly…