Trefil captured the Worthington Gwent and District Cyrus Davies Cup for the seventh time, despite being behind at the interval.
Hafodyrynys, who have never won the cup, gave a good effort, just being outscored 4-3 on the try-count at Glan-yr-Afon Park, the home of Blackwood RFC.
It wasa Trefil who opened the scoring after 15 minutes when Leigh Medlicott sent flanker Adam Taylor across, but Hafodyrynys hit back immediately with a sol from flanker Gethin Foxwell.
Hafodyrynys then took the lead when Greg Hipkiss made ground and Foxwell sent wing Stephen Woodward in, but scrum half Lee Davies pulled Trefil back with a penalty that left them 10-8 down at half-time.
Despite a lot of defending, Trefil broke out with lively full back David Walters and fly half Justin Owens combining to send wing Stuart Jones over and with ten minutes remaining Walters sliceed through to give wing David Rice a try-scoring pass.
Replacement Geraint Reynolds dived in from a linout and Owens converted, but Hafodyrynys fought back and replacement centre Anthony Slocombe burst over in injury time. Prop Lee Farrar collected the cup in front of a good-sized crowd.
Hafodyrynys - W Saunders; S Woodward, D Williams, Greg Hipkiss, S Davies; N Trigg, M Hodges; D Angell, D Hall, D Jenkins, R Phelps, R Topp, Gavin Hipkiss, D Tovey (capt), G Foxwell. Reps: K Evans, R Testagrossa, T Goff, C Wall, A Slocombe, V Jenkins, R Goodway.
Tries: Stephen Woodward, Gethin Foxwell, Anthony Slocombe.
Trefil - D Walters; S Jones, Leon Davies, Nicky Davies, D Rice; J Owens, Lee Davies; J Reynolds, P Harriman, L Farrar (capt), D Dowdsell, A Edwards, S Thomas, L Medlicott, A Taylor. Reps: S Stradling, D Stradling, Neil Davies, G Reynolds, D Griffiths, M Dunster, J Mantle.
Tries: Stuart Jones, Adam Taylor, David Rice, Geraint Reynolds. Con: Justin Owens. Pen: Lee Davies.
Referee - Gary Mascetti (Usk).