Kyle Busch finished second, followed by Greg Biffle, Dale Earnhardt Jr. and Gordon. Polesitter Denny Hamlin was sixth.
It was a rough day for Matt Kenseth, who came into Sunday's race with the Sprint Cup Series points lead but was taken out of the race in a late collision with Joey Logano.
Johnson also won the Brickyard in 2006, 2008 and 2009.
"They're that good, and they deserve it," Gordon said
The victory puts Johnson among some legendary names in the historic track's record books. Gordon is the only other four-time Brickyard 400 winner. Only three drivers have won four Indianapolis 500s: A.J. Foyt, Al Unser Sr. and Rick Mears; Mears was one of Johnson's racing heroes growing up.
Formula One ace Michael Schumacher won the U.S. Grand Prix five times on Indy's road course configuration.
But Johnson's big moment was seen by another disappointing crowd at what still is considered one of the Sprint Cup Series' most prestigious races.
After drawing huge crowds for more than a decade after the first NASCAR race at Indianapolis in 1994, attendance has been sagging in recent years. The front-stretch stands were fairly full, but there were sparse crowds in the turns.
Jeff Burton's flat tire brought out a caution with 36 laps to go, giving the leaders an opportunity to make their final pit stops.
Johnson, Brad Keselowski, Gordon and Busch all took four tires on their stops but Biffle only took two tires, allowing him to come out of the pits first.
The race restarted with 31 laps to go, with Biffle taking the lead and Johnson fighting off Busch to hold on to second.
Biffle's lead didn't last long, as Johnson went around him on the front stretch with 29 laps to go.
Logano then spun and collected Kenseth, leaving his car banged up and smoldering. Kenseth was OK but his points lead was gone.
"Everybody was just running everybody in the back, and you could see it was just a matter of time before the wreck happened," Kenseth said.
Johnson got a flawless restart when the race went back to green with 20 laps to go, then pulled away from Busch in the closing laps of the race.
Keselowski was going for a weekend sweep after winning the Nationwide Series race at Indianapolis on Saturday. But Keselowski's car got loose after the race restarted on lap 101, and he slid back to seventh.
Sprint Cup standings
1. D. Earnhardt Jr. 731
2. M. Kenseth 717 -14
3. G. Biffle 709 -22
4. J. Johnson 704 -27
5. D. Hamlin 667 -64
6. K. Harvick 653 -78
6. M. Truex Jr. 653 -78
8. T. Stewart 652 -79
9. B. Keselowski 649 -82
10. C. Bowyer 643 -88
11. K. Busch 588 -143
12. C. Edwards 582 -149