Updated

Arizona Republican Martha McSally on Wednesday was declared the winner of the final 2014 congressional race -- giving her party its largest House majority in 83 years when the new Congress convenes next month.

McSally defeated Democratic incumbent Rep. Ron Barber by just 167 votes, in the third contest between them in three years.

Barber was a staffer for Rep. Gabrielle Giffords when he and the congresswoman were wounded during a political event in Tucson in January 2011.

Barber then won a special election to finish Giffords' term. He defeated McSally in 2012 to win a full term in Congress, in a race separated by fewer than 2,500 votes.

McSally, the first U.S. female Air Force combat pilot, won this rematch in a year in which the GOP made big gains across the country. The results of the mandatory recount means Republicans will hold their largest House majority since the administration of President Herbert Hoover, controlling 247 seats to 188 for Democrats.

“Martha McSally has broken barriers her entire life, and I know she will continue to fight for the issues she is passionate about in Washington,” said Oregon Rep. Greg Walden, chairman of the National Republican Congressional Committee. “From growing jobs to securing our border, Martha will be an effective and common-sense representative for southern Arizona.”

The Tucson-area district is one of the most competitive in the nation.

Giffords narrowly won her 2010 race over a Republican challenger in the months before the shooting that killed six and wounded her, Barber and 11 others.

McSally led Barber by 161 votes after all ballots were counted last month. But the margin was so tiny that it triggered an automatic recount, which added six votes to her margin.

Judge Katherine Cooper announced the results, roughly six weeks after the Nov. 4 election, in court Wednesday before lawyers for both candidates. There were no objections.

Barber had fought in several venues to get additional votes counted, but was turned away at every effort. He tried to get the board of supervisors from Pima and Cochise counties and the secretary of state to order rejected provisional and early ballots counted. When that failed, he turned to a federal judge to get the provisional ballots counted.

Separately, a group of voters tried to get the state Supreme Court to halt the recount because of the computer program used. That, too, was rejected.

McSally's win gives the GOP a 5-4 advantage in the Arizona congressional delegation.

The Associated Press contributed to this report.