SAN DIEGO — President Trump’s welcome committee, a few hundred strong, many dressed in the colors of the flag, gathered on Tuesday at an industrial park not far from the border, and not far from the prototypes of the president’s border wall.

It was part pep rally and part celebration of what they viewed, with the president’s trip, as a fulfillment of a promise, the reason they voted for him: the construction of a wall to keep undocumented immigrants away.

A few miles of freeway to the west, Mr. Trump’s opponents gathered in the parking lot of a hilltop church, overlooking Mexico. The distance between the groups was by design. Organizers from each side said they wanted to stay separate, and avoid clashes.

It was Mr. Trump’s first visit to California since his election in 2016, a state with which he has had particularly difficult relations. After landing on Tuesday, he inspected the series of wall prototypes, accompanied by United States Border Patrol agents on horseback, and talked about the need for a stronger barrier along the border. “People are pouring in,” he said. From here, he headed to a military base to give a speech and then to Beverly Hills for a fund-raiser before spending the night in downtown Los Angeles.