Giffords was in Tucson Tuesday night to congratulate Barber, her former aide and fellow Democrat. Barber told supporters, "Life takes unexpected turns and here we are, thanks to you." Giffords hugged him and kissed his forehead.
Barber beat Republican Jesse Kelly, who narrowly lost to Giffords in 2010, 52 to 46 percent.
A replay is likely in November with both candidates expected to run for a full term in Congress. By then, redistricting will boost the number of registered Democrats.
Democratic officials argue that the victory sets the stage for them to win back control of the House. Republicans predict that Democrats won't fare as well when President Barack Obama heads the ticket.
Giffords had stepped down earlier this year to focus on her recovery from the gunshot wound she suffered in 2011 during a shooting rampage outside a Tucson, Ariz., grocery store that killed six people and wounded 13, including Barber.
The Associated Press contributed to this report.