In a statement, Valadao thanked his supporters and said it had been an “honor of a lifetime” to serve his constituents in California.

“There is no doubt we are disappointed in the results but we can take pride in knowing that we brought about real, tangible change,” Valadao said in the statement. “We have reduced taxes for middle class families, made huge strides in our battle for water, reformed the dairy industry for thousands of California farmers, improved access to healthcare for families throughout the Valley, and given our troops the support they deserve.”

Several national news outlets, including CNN, had previously projected the race for Valadao. However, vote reports after election night tightened the margin significantly and eventually put Cox in the lead.

Of all the California GOP members up for re-election in districts won by Hillary Clinton in 2016, Valadao was viewed as the congressman with the best chance of holding his seat.

The son of an immigrant from the Azores Islands in Portugal, Valadao has deep roots in the Central Valley, where his family owns several dairies.

He often differed with President Donald Trump on immigration policies — a reflection of the predominantly Latino makeup of his district. As a member of the House Appropriations Committee, he had skillfully tended to the needs of his district by getting funding for projects back home.

Trump’s harsh immigration rhetoric, his trade policies that threatened Central Valley farmers and the distaste for the Republican tax bill in California, which Valadao supported, ended up being too much of a drag on the Central Valley congressman.

While Cox was ultimately able to stay competitive in fundraising during his race against Valadao, he was hardly viewed as one of the Democrats’ strongest contenders at the outset.

The engineer founded several companies that process nuts, a major export from the Central Valley. He had run for Congress in 2006 and lost by double digits.

In a statement on his victory, Cox thanked his family and volunteers.

“Even when the outlook may have seemed dim, they never gave up. This campaign was fueled by their energy and passion to make a positive difference in lives of the hard-working people here in the Central Valley,” Cox said. “Voters across the district resonated with our message of expanding health care, creating good jobs, and fighting for our families’ futures.”

Cox founded and is the president of the Central Valley New Market Tax Credit Fund, which raises money for projects in lower income neighborhoods.