The young Bluebirds had two players sent off in their play-off final against Sheffield Wednesday at Hillsborough.
Cardiff City, champions of Professional Under-18 Development League South, had Dan Griffiths and Kieran Evans dismissed and finished the final with nine players.
Hosts Sheffield Wednesday were winners of PDL North, edging out Leeds United in the title chase, and led 2-0 at half-time.
First half goals from Charles Hagan and Charlie Reaney fired the Owls into a commanding position at half-time before a Cardiff fightback saw them halve the deficit through Griffiths.
Moments later, though, Wednesday restored their two-goal cushion when substitute Elliott Vasalo scored with almost his first touch before Margetson netted another for the Bluebirds, setting up a tense finale.
But City then had Griffiths and Evans sent off for second bookable offences.
The Bluebirds started slowly, but grew into the game and full-back Keenan Pattern had the first chance when he headed straight at Owls goalkeeper Josh Render from a corner.
Wednesday took the lead on 27 minutes when Hagan finished calmly beyond George Ratcliffe in the Bluebirds goal.
Cardiff responded almost immediately when Conor Davies went on a bursting run from deep, only to be blocked off by Declan Thompson at the vital moment.
Wednesday doubled their lead three minutes before half-time when Liam Waldock won possession back in the middle of the pitch. It was midfield player Reaney who collected a pass and fired a powerful effort beyond Ratcliffe at the near post.
Cardiff started the second half the brighter. First, Isaak Davies was thwarted by a good save and Evans went even closer, seeing his venomous effort strike the underside of the crossbar from distance.
The encounter was now proving to be end-to-end as Cardiff captain Sam Bowen headed straight into the arms of Render from six yards after connecting with Conor Davies cross from the right.
City’s second half persistence eventually paid dividends on 78 minutes when striker Griffiths stabbed the ball home from close range.
That sparked a hectic few moments at Hillsborough as Wednesday almost instantly restored their two-goal advantage when substitute Vasalo pounced on a defensive error and buried the ball beyond Ratcliffe.
But in what was an action-packed second half, Cardiff hit back once more, this time through a Margetson header from a corner.
And that was not to be the end of the drama with Griffiths sent off for a second bookable offence in the 89th minute, while Cardiff were reduced to nine men in stoppage time when Evans was also booked for a second time.
Sheffield Wednesday: Render, Dawodu, Rice, Thompson, Ellery, Waldock, Hagan (Farmer 90), Shaw, Reaney, Grant, Hammoud (Vasalo 79)
Cardiff City: George Ratcliffe, Connor Davies, Ryan Kavanagh, Ben Margetson, Joel Bagan, Keenan Patten, Sam Bowen (capt), Isaak Davies, Kieran Evans, Sion Spence, Dan Griffiths. Subs: Warren Burwood (gk), Harry Pinchard, Ntazana Mayembe, Siyabonga Ligendza, Sam Parsons.