Barraclough, 28, was one of the Marlins' best relievers, going 15-12 with 11 saves and a 3.21 ERA in 227 appearances over four seasons with the team.
Last season, Barraclough set a career high with 10 saves and went 1-6 with a 4.20 ERA and 60 strikeouts in 55 2/3 innings pitched. He allowed one hit in 36 at-bats in June, when he was chosen NL reliever of the month, but struggled with his command the rest of the season.
Barraclough's ERA ballooned to 10.24 over his final 24 games and he lost the Marlins closer's job.
The Nationals are in need of relievers after jettisoning Shawn Kelley and Brandon Kintzler late this season.
The deal helps the Marlins in their pursuit of top international free-agent Victor Victor Mesa, a Cuban outfielder who tried out for major league scouts at Marlins Park last week.
The Associated Press contributed to this report.