WASHINGTON - California Democrat TJ Cox declared victory Wednesday evening in California's 21st Congressional District, a victory that, if it holds, would allow Democrats to gain 40 seats in the House.

On Election Day, Cox trailed by about 5,000 votes and multiple outlets, including the Associated Press, called the race for Republican U.S. Rep. David Valadao. But since then, Cox has picked up votes and as of Wednesday, was leading by 506 votes.

Votes still are being counted in two counties – Fresno and Kern – but balloting from those areas have favored Cox in post-Election Day updates, prompting him to declare the race over.

"I am elated to announce that we have won," Cox said in a statement. "Voters across the district resonated with our message of expanding health care, creating good jobs and fighting for our families' futures. I am truly humbled to have received so much support.

He thanked his family and supporters for sticking by him even when "the outlook may have seemed dim," adding, "now that the election is over, it's time to get to work."

More:California Democrat takes vote lead after trailing 7 points on election night

More:Democrat Anthony Brindisi beats Claudia Tenny, flipping New York House seat

Valadao had declared victory on Election Day, but slowly Cox chipped away at Valadao's lead as votes were tallied. The AP retracted its race call Monday in light of the new vote total.

Valadao did not immediately respond to Cox’s announcement.

While the midterm elections delivered mixed results around the U.S., it affirmed California’s reputation as a Democratic fortress.

If Cox’s lead holds, Democrats will have picked up seven GOP-held seats in California and will begin the new session with a 46-7 advantage in the state’s congressional delegation.

Democrats held every statewide office – again. The party holds a supermajority in both chambers of the state Legislature, and a 3.7-million advantage in voter registration. There wasn’t even a Republican on the ballot for U.S. Senate for the second consecutive election.

Also Wednesday, Republican Rep. Claudia Tenney conceded in the race for New York's 22nd Congressional District. Her Democratic challenger, Anthony Brindisi, was the 40th House seat taken by Democrats in this month's elections.

Contributing: William Cummings, Associated Press