Keselowski held the provisional pole after turning a lap at 195.419 mph early in the third and final qualifying round, but Stewart waited until the end of the round to make his attempt. The three-time Sprint Cup champion was clocked at 195.454 mph as time expired in the session.
Stewart, who missed the final 15 races of the 2013 season due to a leg injury, claimed his 15th career pole in the series but his first since September 2012 at Atlanta. He became the seventh different pole winner in as many races this season.
This was also Stewart's second pole in 24 starts at Texas. He has won at this 1.5-mile racetrack twice (fall events in 2006 and '11).
Since NASCAR began using its new "knockout-style" qualifying format the first weekend in March at Phoenix, Keselowski has earned a front row starting position in every race except last weekend's event at Martinsville, where he started 14th.
Kevin Harvick, who is Stewart's teammate at Stewart-Haas Racing, qualified third. Harvick set a new track qualifying record at Texas with a lap at 198.282 mph during the first round of qualifying.
Greg Biffle took the fourth spot, followed by Carl Edwards, Denny Hamlin, Trevor Bayne and Ryan Newman.
Qualifying ninth through 12th were: Marcos Ambrose, Joey Logano, Kurt Busch, who won at Martinsville, and Jeff Gordon.
Jimmie Johnson, the six-time and defending Sprint Cup champion and three-time race winner at Texas, failed to advance into the final round of qualifying for the first time this season. Johnson will start 16th.
Other notable drivers and their starting positions include: Dale Earnhardt Jr. (19th), Danica Patrick (24th), Matt Kenseth (26th) and Kyle Busch (29th). Busch won last year's spring race at Texas.
David Stremme, Ryan Truex, Joe Nemechek and J.J. Yeley failed to qualify for Sunday's Duck Commander 500 at Texas, which is scheduled to start just after 3 p.m. ET.
Swim Week Miami Beach 2014 [PHOTOS]