Donald Trump waited more than a year to visit California, a stronghold for his Democrat rivals. When he arrived, it was to tout the most enduring and divisive symbol of his presidency - his border wall with Mexico.

His arrival in America’s most populous state which is also home to the country's largest undocumented population was akin to a foray into enemy territory.

Democrats there would like to see him removed from office, while members of his own Republican Party are hoping his unpopularity doesn't drag down their re-election bids.

His tour of border wall prototypes near San Diego also reinforced the message that propelled him to the White House.

The President has long used liberal California as a reason for his hard line on immigration, vilifying its elected officials and lambasting city and state “sanctuary” policies that constrain law enforcement from working with Immigration and Customs Enforcement. Escalating the confrontation, the US Justice Department last week sued over those policies.

California meanwhile has repeatedly sued the Trump administration over a number of policy decisions.

Rather than putting that rivalry aside for his visit, the President touted it. He previewed his trip by tweeting that the state's laws “put the safety and security of our entire nation at risk”.

He resumed the critique upon landing in the state, dismissing California Governor Jerry Brown as having done “a very poor job”, repeatedly excoriating sanctuary laws and urging Congress to revoke funding for sanctuary cities, a tactic that has been rejected in court.

Capturing the fractured political landscape Mr Trump, he was met with duelling demonstrations. Rival protesters shouted both their support and antipathy for their leader at each other from across police lines.

Flag-waving supporters chanted “USA” at a rally near the border.

A pro-Trump group called "San Diegans for Secure Borders" organised a rally to convey that the President is “absolutely welcome in San Diego”.

Its founder Jeff Schwilk, who has been a prominent member of an anti-illegal immigration group called the Minutemen said Mr Trump "never wavered" from immigration reform "being his top issue".

Life on the US-Mexican border Show all 12 1 /12 Life on the US-Mexican border Life on the US-Mexican border Tijuana, Mexico A house stands next to a section of the border fence separating Mexico and the US Reuters Life on the US-Mexican border Tijuana, Mexico The border fence in Tijuana stretches all the way to beach Reuters Life on the US-Mexican border Tijuana, Mexico Migrants can often be spotted trying to cross the rusty barrier Reuters Life on the US-Mexican border Tijuana, Mexico Joaquin, 36, a chef from Guatemala who says he was deported from the US Reuters Life on the US-Mexican border Tijuana, Mexico A shack stands next to a section of the border fence Reuters Life on the US-Mexican border Tijuana, Mexico Tourists pose for a picture at the border Reuters Life on the US-Mexican border Tijuana, Mexico A family burns rubbish near the fence Reuters Life on the US-Mexican border Tijuana, Mexico Joaquin makes a living by selling rubbish Reuters Life on the US-Mexican border Tijuana, Mexico ‘Neither Trump nor the wall is going to stop anyone,’ says Pedro Reuters Life on the US-Mexican border Tijuana, Mexico Mexicans have built homes right next to the fence Reuters Life on the US-Mexican border Tijuana, Mexico Mexican Carlos, 27, who says that he was deported from the United States, heats up tortillas at his house near the double fence that separates Mexico and the US Reuters Life on the US-Mexican border Tijuana, Mexico A girl climbs stairs near a section of the fence

Just as Mr Trump’s immigration stance animated conservative voters, his election has galvanised elected officials and the liberal base in California. Groups representing the spectrum of the “resistance” to Mr Trump organised demonstrations, among them a local Women’s March chapter and immigration advocates.

Some young people known as Dreamers, who entered the country illegally as children but have grown up in the US, have seen Mr Trump end a programme that offered protection from deportation, planned a vigil to highlight what they callled “hateful rhetoric and xenophobic tendencies”.

A Democratic member of Congress, Juan Vargas, drew applause for noting he has repeatedly voted for impeachment.

“Sadly we’ve spent million of taxpayer dollars building prototypes that don’t do a single thing to protect the country. All they do is create a backdrop for the president to come here and grandstand”, said Christian Ramirez, who headed the Southern Border Communities Coalition and is running for a San Diego City Council seat whose district abuts the border.

Donald Trump: 'if you don’t have a wall system, we’re not going to have a country'

Democrats hold all the levers of power in the California state government, and Mr Trump lost the state by millions of votes. It is also a fulcrum on which control of Congress could turn, with the Democratic Party aiming to unseat 10 Republican members as they look to create a swing of 24 seats in the House.

That has left some vulnerable incumbents walking a delicate balance, hoping not to alienate conservative voters while casting a wary eye towards a President who is politically toxic for many moderates.

Days before his visit, the California Republican Party embraced the President with a fundraising email highlighting the Department of Justice's decision to sue the state..

It said Governor Jerry Brown and California Attorney General Xavier Becerra were “bragging” about defying the federal government.

But some local Republicans were absent when the President toured the border. The San Diego County Republican Party did not make any plans for Mr Trump’s visit, with a representative saying they were too busy planning for an annual fundraiser.

Rocky Chavez, one of the party's congressional candidates was also conspicuous by his absence.

Republican Rep Duncan Hunter, whose San Diego-area district is among those Democrats are hoping to turn, was initially planning to return to Washington but ended up heading to the border after a last-minute call from the White House.

However Matt Rexroad, a political consultant for California Republican Party predicted Mr Trump’s visit would not affect tight races. He said it did little more than offer a helping of “red meat” to both liberals and conservatives.

“For the administration they get to go back to the East Coast or the Midwest and say ‘we’re sticking it to California’, said Mr Rexroad, whose clients include one of California's Republican congressmen, Steve Knight.