FC Gawthorpe were edged out 3-2 as Wakefield City struck late on in the annual Memorial Cup game at Beck Lane.
The charity match is played as a curtain raiser to the local football season between the Wakefield District Cup winners and Heavy Woollen Wheatley Cup winners.
Gawthorpe went into the game on the back of a treble winning season which saw them clinch the Wakefield League Division One title, the league cup and Wheatley Cup.
However, it was Wakefield Cup winners City who struck first with a goal in the opening stages.
They were awarded a disputed penalty, which was duly converted.
Both sides had good chances but excellent goalkeeping at both ends meant it remained 1-0 at half-time.
Gawthorpe were on top at the start of the second half, but against the run of play, City broke and doubled their advantage.
With 20 minutes remaining, Daniel Coucill pulled a goal back when he headed home a Gawthorpe free-kick to give his side hope.
Greg Snowden was denied an equaliser when the City goalkeeper superbly tipped his goalbound effort over the crossbar but just two minutes later they were on level terms.
Another disputed penalty gave Timmy Clarke chance to slot home and he duly obliged to set up a storming finish.
Two minutes from full-time City struck the decisive blow with a well-taken goal which clinched victory and the Memorial Cup.
The game raised just over £500, which will be donated to the Kirkwood and Wakefield Hospices.
Gawthorpe have drawn Middleton Park Reserves in the first round of the West Riding County Trophy, to be played on October 5.