It was probably the most talked about campaign ad in one of the nation's hottest political contests, the tight race for California's 21st Congressional District seat.

The name of former U.S. President Barack Obama was featured in a positive light as part of a TV ad for dairyman David Valadao, the Hanford Republican running against Democratic incumbent T.J. Cox of Selma. It said Valadao had worked with Obama to bring more water to the Central Valley.

Here was a former three-term congressman, who President Donald Trump made a point of endorsing during his February rally in Oildale, now aligning himself with a Democrat whose signature legislative victory, the Affordable Care Act, Valadao voted to repeal in early 2017.

But if Obama's name in the ad appeared out of place, it was not. In fact, it says a lot about the race and the district itself.

When Cox defeated Valadao to win the seat in 2018, the race was decided by fewer than 900 votes. Valadao came back strong in March, beating Cox 53.1 percent to 36.1 percent in a four-candidate field.

Valadao, 43, has solid name recognition in the 21st District. But as of July 3, 44 percent of its voters are registered Democrats. Plus, in the 2018 presidential election, the majority Hispanic district stretching from northern Fresno County to Lamont chose Hillary Clinton over Trump by a margin of 15½ points.

In an election many see as a referendum on Trump's performance, observers say Valadao, much more than Cox, wants to satisfy both sides.

"It's a dance," said Jeanine Kraybill, an assistant professor of political science at Cal State Bakersfield. "It does show that (Valadao) knows that he has to have this multifaceted approach."

Ivy Cargile, also an assistant professor of political science at CSUB, said it's as though Valadao assumes the district's Democrats and Republicans "aren't watching all the same thing."

Valadao said as a congressman he'll buck his own party if he thinks it's in his district's best interest. That appears to have happened in June 2018 when he voted against an ultimately unsuccessful, hard-line immigration reform bill that party leaders including Rep. Kevin McCarthy, R-Bakersfield, had supported.

Valadao also called attention to his support for bipartisan legislation including 2016's Water Infrastructure Improvements for the Nation Act, which has benefited projects including irrigation canal investment bills championed by Cox.

"The purpose of the ad (featuring Obama's name) is to show that I can work across the aisle," he said, adding he's not against working with whoever occupies the White House. "If it's something I agree with I'll work with him (Trump or Democratic presidential nominee Joe Biden) on it."

The Republican challenger explained that he opposed ACA, also known as “Obamacare,” because it ended up raising health insurance costs in his district. He said his own legislative action on health care expanded a program helping medical clinics attract physicians to communities like those in his district.

(Obama's communication director, Katie Hill, told local TV station KGET-17 it condemned Valadao's ad for falsely implying the former president's support, which she noted went instead to Cox.)

Cox, 57, points to more than two dozen bills he has introduced to address rural health challenges, care for military veterans and investments in education.

The canal bills Valadao referred to, which Cox says he shepherded all the way through annual government funding processes, directed repair money to the Friant-Kern and Delta-Mendota canals to bring "safe, reliable water to taps in the most rural communities of the Central Valley," the Democratic incumbent said by email.

Cox also makes the point Valadao almost always voted in favor of Trump's agenda during his last two years in office.

"While David Valadao was a yes man for the worst president in our nation’s history, I’ve already worked with colleagues across the aisle to deliver for the Valley," Cox stated.

Accusations have been made against both candidates. Valadao's campaign has alleged Cox failed to meet deadlines for paying taxes totaling more than $100,000, which the Democrat's campaign says were levied in error and have since been resolved.

Meanwhile, reports have surfaced of a lawsuit a former employee of Valadao's family dairy filed regarding an accident that led to the worker's hand being accidentally severed on the job. The Visalia Times-Delta newspaper reported a Kings County jury found the dairy four-fifths responsible and an equipment manufacturer one-fifth responsible. Valadao's campaign called Cox's spotlight on the case exploitation of tragedy for political gain. 

The race is by all accounts much too close to call.

"It's probably going to be a nail-biter and we're not going to know the results right away," after the Nov. 3 general election, CSUB's Cargile said.

Editor's note: This story was updated to include a report that Obama disavowed Valadao.)