The tag-team race came down to an eight-car sprint -- actually, four pairs of cars -- with only the guys at the front of the duos having a chance to win the Aaron's 499.
After laying back most of the day, five-time series champion Johnson came on strong at the end for his 54th career victory and first of the season.
"We were just the lucky guy at the end with a good run," Johnson said. "We had some big mo on our side, and off we went."
Coming out of the fourth turn, the No. 48 car dipped right next to the yellow line, surged past Hendrick Motorsports teammates Jeff Gordon and Mark Martin and got to the finish line just ahead of Bowyer in a four-wide dash down the long finishing straight at Talladega Superspeedway.
"What a bummer," said Bowyer, who led a race-high 38 laps. "I saw him coming."
Earnhardt, the fourth Hendrick driver, finished fourth and essentially gave up a chance to claim his first win since 2008 by deciding he was more comfortable pushing Johnson than getting pushed.
"I can't thank Junior enough," said Johnson, who tried to give Earnhardt the checkered flag but was rebuffed. "He made the decision that my car was faster leading. And the way these things are finishing up, the lead car's going to get the win. In some respects, he was more worried about the team having a good performance than anything."
Kevin Harvick, who was Bowyer's pusher, wound up fifth. Carl Edwards almost got into the mix as well, going right up against the outside wall with Greg Biffle on his bumper but didn't have enough room to pull it off, finishing sixth.
Biffle was seventh, while Martin dropped back to eighth.
The finish matched the closest since NASCAR went to electronic timing -- Ricky Craven edged Kurt Busch in 2003 at Darlington -- and made up for a day of lackluster racing with this new tandem style, which the drivers began using at the Daytona 500 and really perfected at this 2.66-mile trioval.
Twenty-six leaders swapped the top spot 88 times, tying the record set in last year's spring race at Talladega. Many of those changes were carefully choreographed by pairs who were merely trying to stay out of trouble, conserve their cars and give themselves a chance at the end.
"If you didn't like that finish and forget about the race, there's something wrong with you," Bowyer said. "It always seems to fix itself at the end of these restrictor-plate races. We always have a hell of a finish."