Bayne, the surprise winner at the Daytona 500 nine months ago, wrested the lead from Roush Fenway Racing teammate Carl Edwards after the final restart with six laps to go.
He then fended off a challenge from Hamlin -- subbing for Kyle Busch in Joe Gibbs Racing's No.18 Toyota -- to capture a victory in his 77th Nationwide start.
Busch was suspended from the Texas Nationwide and Sprint Cup events for retaliating against Ron Hornaday Jr. in Friday's Camping World Truck Series.
Edwards finished third, while Clint Bowyer and Brad Keselowski rounded out the Top 5.
Celebrity Breakups and divorces of 2014 [PHOTOS]