The Avalanche set a team record for road wins with the victory, improving to 25-10-3 away from Denver.
David Perron scored for the Oilers, who had a two-game winning streak come to an end.
Colorado started the scoring at 4:13 of the first after Stastny swatted the puck in through the legs of an Edmonton defender from the side of the net after goalie Ben Scrivens had made the initial stop on Gabriel Landeskog. It was Stastny's 23rd goal of the season.
The Oilers tied the game on the power play at 16:58 of the opening period as Perron banked the puck off the skate of defenseman Nick Holden and past goalie Jean-Sebastien Giguere. It was Perron's team-leading 28th goal of the season.
However, the Avalanche restored their lead just 12 seconds later as Johnson skated past Oilers defender Jeff Petry and beat Scrivens up high.
Both goalies were solid in the scoreless second period, particularly Scrivens, who came across to make a huge toe save on Stastny after a bad bounce off the glass with two minutes left. The shots favored Colorado 23-19 through 40 minutes.
The Avalanche came into the game with a record of 34-0-2 when leading after two periods.
Colorado took a 3-1 lead at 7:34 of the third on a power-play goal as Barrie came in from the point and took a shot through traffic that beat Scrivens high to the glove side.
The Avalanche made it 4-1 with just under four minutes left to play as McGinn smacked the puck into the net before Ryan Nugent-Hopkins could clear it for his 19th of the season.
Both teams return to the ice on Thursday as the Oilers play the third game of a season-ending four game homestand against the Los Angeles Kings. The Avs are on the road for their final four matches, playing the second of a four game trip in Vancouver against the Canucks.
Notes: It was the third and final meeting between the teams this season. Edmonton started out with an 8-2 win over the Avalanche on Dec. 5, however the Avs bounced back with a 4-3 win two weeks later in Colorado. ... Colorado is one of the few teams that the Oilers have had much success against in recent years, coming into the game with a record of 12-4-4 in their past 20 games against the Avalanche. ... Oilers forward Taylor Hall came into the game on a high note, having earned the NHL's first star status on Monday for his play last week. Hall scored two goals and added seven assists in four games to collect the honor. ... Out with injuries for the Avalanche were forwards Cody McLeod (ankle), P.A .Parenteau (knee) and Matt Duchene (knee). ... Absent from the Oilers lineup were forwards Jesse Joensuu (ankle), Tyler Pitlick (knee), Ryan Jones (torn PCL), Luke Gazdic (shoulder), Nail Yakupov (ankle) and defenseman Andrew Ference (chest).