The victory by .112 of a second was the first win of the year for the four-time champion and his third at Kansas Speedway.
Gordon, who started the race leading the series in points, virtually assured himself a spot in the season-ending Chase for the NASCAR Sprint Cup.
"It's a weight lifted off this team's shoulders," Gordon said. "We've been leading the points, but we needed to get to Victory Lane."
"This has always been one of my favorite tracks," Gordon said. "This was a very, very special win."
Harvick finished second after leading the most laps -- 119 -- in the race and making an impressive charge to Gordon's rear bumper on the final lap.
"Just ran out of laps at the end," Harvick said.
He said running out of fuel as he headed to pit road on his final pit stop allowed Gordon to move past him and, ultimately, get the win.
"I was looking at the fuel pressure gauge instead of the tach and lost a bunch of time down pit road and off of pit road and wound up getting stuck behind the 24 (Gordon)," Harvick said.
Patrick had by far her best night on a non-restrictor plate track. She started ninth, hung tough for the first half of the race and then began moving forward. On Lap 162, she blew past both Tony Stewart and Earnhardt and moved to third place.
A slow pit stop during a caution that occurred on Lap 177 knocked her back to seventh but she again hung tough and notched the best finish of her 57-start Sprint Cup career.
It was a fluke-free finish, too, teammate Harvick said.
"She's run well all weekend. Qualified well, raced well all night," he said.
"That was by far the most consistent up-front car" she has had, Patrick said over her radio after the race. "All I wanted to do was stay up front and I did."
Perhaps with an assist from Harvick, who has been having talks with the 32-year-old driver. What kind of talks?
"I guess one thing I did tell her was to quit thinking about it and mash the gas," he said. "Sometimes your car is never going to be perfect and you just have to take what it will give you and expect that every time you pit it's going to get better and if it's not, you adjust and move on."
Patrick said the talk with Harvick "definitely paid off in qualifying for sure. And it does pay off in the race, too."
And her reaction at the finish?
"Honestly, the most rewarding part of my night was probably when I drove around the outside of the No. 48 (Johnson) on a restart," she said. "I say that with all the respect in the world. It's a big deal because he is Jimmie Johnson. Aside from that, I was really just overall proud that we stayed up front. That was the biggest thing."
Harvick broke clean from his pole position on the start and began to move out. By Lap 15 of the 267-lap event, he had a two-plus second lead. Behind him, the field was well spread out. By Lap 33, the lead was three seconds.
He would lead 89 laps in dominating fashion during the first half of the race.
However, the night went bad for Harvick when a spin by Marcos Ambrose on Lap 110 produced a caution. Harvick had pitted as the leader six laps earlier while most of the rest of the field did not. That put him a lap off the pace. He did get the free pass but when the race went green, he was outside of the top 15.
Harvick was not done, however. He slowly worked his way back forward and on a restart on Lap 195 climbed to third place. On a restart on lap 207, he was second, below Logano, and moved back to the lead between Turns 3 and 4.
He lost the lead to Gordon during green flag pit stops 40 laps from the end and could never get back to the lead.
Asked if running out of gas heading into the pits cost him the victory, Harvick said, "I can't say that. I mean, even though it was out of gas, with these EFI (electronic fuel injection) units, it still runs and I should have been paying attention to my pit road speed lights and should have gotten off pit road better.
"It was my fault coming down pit road too slow."
The first night race at Kansas dashed some hopes.
Hopes for a victory on what he considers his home track were crushed for Jamie McMurray of Springfield, Mo. after his car blew a tire, broke an oil line and burst into flames early in the race.