On December 12, 2018, the Reds traded Rainey to the Washington Nationals for Tanner Roark. Rainey was called up to the Nationals from the Class-AAA Fresno Grizzlies on May 18, 2019, and swiftly became one of manager Dave Martinez's go-to relievers. He earned his first career win in relief on June 1, beating Roark and the Reds at Great American Ball Park. In 2019 he was 2-3 with a 3.91 ERA in 52 relief appearances, as he struck out 74 batters in 48.1 innings (13.8 per nine innings). The Nationals finished the 2019 year with a 93-69 record, clinched a wild card spot, and won the World Series over the Houston Astros. Rainey pitched 6.2 innings in the 2019 playoffs including throwing 2 strikeouts and finishing Game 3 of the 2019 NLCS, the first ever NLCS game at Nationals Park and in Washington, DC history. Rainey pitched 20.1 innings of 2.66 ERA ball in 2020, going along with 32 strikeouts and a 1-1 record, however after experiencing forearm tightness in mid-September 2020, Rainey sat out the remainder of the season.