Red-hot favourites Kilkenny were pushed all the way by a skilful and determined Westmeath in Mullingar.
The Cats were nine points ahead at half-time (2-5 to 0-2), with well-taken goals from Johnny Hayes and the outstanding Kevin Kelly putting them firmly in control.
Despite having the wind advantage, the home side failed to score from play in the opening half-hour, while Aonghus Clarke missed a range of scoreable frees.
However, Westmeath were transformed on the change of ends and when Niall O'Brien scored a goal in the 54th minute, the sides were level.
The same player had three great scoring opportunities in the closing stages, but it was the Kilkenny lads who kept their nerve to qualify for the semi-finals with two terrific late scores from Kelly and substitute Robert Moran.
SCORERS -- Kilkenny: K Kelly 1-6 (0-4f), J Hayes 1-1, D Kearns, R Reid, R Moran 0-1 each. Westmeath: N O'Brien 1-4 (3f), C Scally 0-3f, A Clarke, R Greville 0-2 each.
Kilkenny -- A Duggan; L Hickey, C Doyle, E Morrissey; D Cody, O McGrath, E Moriarty; D Kearns, C Bolger; C Martin, K Kelly, P Vickery; T O'Hanrahan, R Reid, J Hayes. Subs: M Mansfield for Vickery (26), R Moran for Reid (47), D Lenihan for Bolger (55).
Westmeath -- J Moore; T Gallagher, T Doyle, D McDermott; D Fennell, C Scally, L Varley; D Lynch, D McCormack; J Boyle, A Clarke, P Fennell; N O'Brien, D Higgins, R Greville. Subs: M Glennon for McCormack (39), N Kirby for P Fennell (42).
Ref -- J Heffernan (Wexford).