The pair combined to drive in five runs as the Cubs snapped their three-game losing streak.
Bryce Harper hit his 28th home run for National League East-leading Washington, which has lost three of its last four.
Harper homered off the right field videoboard to give the Nationals the lead in the first inning. Cubs starter John Lackey has allowed 27 home runs, tied for the most in the majors.
The Cubs, who were holding a slim lead over the Milwaukee Brewers in the NL Central, came back with a four-run bottom of the first. Jon Jay and Kris Bryant hit back-to-back doubles to tie the game before Contreras' infield single put the Cubs ahead. Avila then smacked a two-run home run for his first hit as a Cub since Chicago acquired him Monday from Detroit.
The Nationals pulled within one with two runs in the fourth. After two singles, Anthony Rendon's sacrifice fly and left fielder Contreras' throwing error brought in one run, and Matt Wieters' two-out single drove in another.
Contreras' two-run home run, his 19th of the season, gave the Cubs insurance runs in the sixth inning. He homered off reliever Matt Grace after Anthony Rizzo singled.
Jay added an RBI single in the seventh for the Cubs.
The Nationals scored a run on shortstop Javier Baez's error on a double-play attempt in the eighth.
Lackey (9-9) allowed three runs (two earned) in five innings. He was 3-0 with a 3.27 ERA in July.
Wade Davis earned his 23rd save despite walking two in the ninth. With two on, he struck out Harper to end the game.
Nationals starter Edwin Jackson (2-2) struck out eight and walked none but gave up four runs in five innings against his former team. He pitched for the Cubs from 2013-15. Previously, he was 3-5 with a 5.89 ERA in 10 career appearances against Chicago. Jackson started in place of left-hander Gio Gonzalez (9-5, 2.66 ERA), who went on the paternity list.
NOTES: The Nationals recalled RHP Erick Fedde from Triple-A Syracuse and placed LHP Gio Gonzalez on the paternity list Saturday. ... RHP Stephen Strasburg (right elbow nerve impingement) is making progress in his throwing program, the Nationals announced Saturday. He has been on the disabled list since July 27. ... Cubs C Willson Contreras made his third start in left field this season Saturday against the Nationals. Contreras replaced Kyle Schwarber, who is batting .192, in left field. Manager Joe Maddon said he wanted to keep Contreras' bat in the lineup. Contreras was hitting .429 during the homestand entering Saturday. ... Cubs C Alex Avila caught RHP John Lackey for the first time since they acquired Avila from the Detroit Tigers on Monday. ... Nationals C Matt Wieters was ejected between the sixth and seventh innings for arguing balls and strikes.