In exchange, the Nationals received minor league outfielder Erik Komatsu.
"Jerry is a valuable addition to our ball club with the injures to Carlos Gomez and Rickie Weeks," Brewers general manager Doug Melvin said. "He is a versatile player who has experience at every position except catcher and pitcher. He also provides an energetic and veteran presence."
Weeks is on the 15-day disabled list after spraining his left ankle Wednesday in a game against the Chicago Cubs, and likely will be out two to six weeks.
Gomez broke his left collarbone July 20 making a diving catch in a game against the Arizona Diamondbacks, and is expected to be out six weeks.
Hairston, 35, hit .268 with four home runs and 24 RBIs in 75 games this season with the Nationals, with whom he played mostly third base and the outfield.
Komatsu, 23, was batting .294 in 93 games with Double-A Huntsville this season. He was taken in the eighth round of the 2008 draft, and was the Brewers' minor league player of the year last season.