Derry clinched the Football League Division 2 title as Brian McIver's gamble of replacing Eoin Bradley with Emmett McGuckin late on paid off.
Bradley's early brilliance helped Derry lead 0-4 to 0-0 but Westmeath fought back to lead 0-10 to 0-7 before the Oak Leafers drew level by the interval.
Play became scrappy and the teams were level at 0-15 to 0-15 late in the game.
However, Ryan Bell and James Kielt points edged two ahead before McGuckin's late goal sealed the win.
Patsy Bradley's form in midfield was one of many positives from Derry's display but the downside from the victory was a serious-looking knee injury sustained by the lively Raymond Wilkinson early in the second half.
The Ballinderry man had to be stretchered off and it must put a doubt over his participation in the Ulster Championship clash against Down.
The big talking point from the game will be McIver's decision to haul off Bradley with 12 minutes to go after he had fired a couple of bad wides.
At the time, it looked a harsh call as Bradley, after a brilliant start, had remained a handful for the Westmeath defence for much of the contest.
However, McGuckin justified McIver's big call as he slammed in Derry's injury-time goal after his leap in the square upset Westmeath keeper Gary Connaughton before he gathered to slam the ball home from close range.
Derry looked in complete control early on as Bradley was causing the Westmeath defence all manner of problems.
Bradley contributed two of Derry's four early points and the Oak Leafers still held a four-point advantage when they led 0-6 to 0-2.
However, Westmeath began to compete well at midfield and showed an ability to kick points from distance as they turned the game on its head by hitting eight of the next nine scores.
Midfielder John Heslin knocked over a couple of glorious points from frees and play with Callum McCormack, Ciaran Curley and the lively Denis Glennon also contributing fine scores.
Derry looked in a degree of trouble at 0-10 to 0-7 down but crucially the Oak Leafers fought back with three straight points in injury-time with James Kielt (two) and Wilkinson on target.
After the sparkling scores of the first half, the play was not as fluent in the third quarter.
Derry did have a great goal chance but sub Colin Devlin saw his shot deflected wide when perhaps a pass inside to the unmarked Bradley might have represented the better option.
Dessie Dolan's introduction for Westmeath looked as though it might prove the difference between the sides as he hit two straight points to edge Pat Flanagan's side 0-13 to 0-12 ahead.
A bad wide from Bradley led to McIver taking immediate action in the 58th minute and Derry were back on terms moments later as Gerard O'Kane had to be content with a point as he blazed over after rounding Connaughton.
Points from James Kielt and Sub Ciaran McFaul edged Derry two ahead but extra-time beckoned as scores from Dolan and Heslin brought the sides level with a minute of normal time left.
However, Derry produced a tremendous scoring burst in injury-time with points from the impressive Bell and Kielt followed by McGuckin's goal.
For good measure, McGuckin added another score before the final whistle.
Derry: E McNicholl; A McAlynn, C McKaigue, G O'Kane; C Kielt, M Lynch (capt), SL McGoldrick; Patsy Bradley, R Bell; D Heavron, J Kielt, E Lynn; B Heron, E Bradley, R Wilkinson. Subs: T Mallon, B McCallion, D Brown, M Bateson, C McAtamney, B Gormley, L Kennedy, D Mullan, C Devlin, C McFaul, E McGuckin
Westmeath: G Connaughton; M McCallion, J Gaffey, K Maguire; D Harte, P Sharry, J Dolan; D Duffy, J Heslin; G Egan, C McCormack, K Martin; D Corroon, C Curley, D Glennon.