Selman's unbeaten 116 anchored Glamorgan's pursuit of 266 in 51 overs, before hitting 14 off the first three balls of the last over.
Four wickets for debutant spinner George Harding also kept Durham in the hunt in the evening gloom.
Paul Collingwood declared when he was on 92 not out to set up a competitive contest.
The Durham captain was set to record his second century of the match, but brought an end to the innings after bad light and rain cost an hour of play after lunch.
Earlier Graham Clark took his first-class best to 72 while Ryan Pringle made a hard-hit 41, but two wickets apiece for Michael Hogan and Andrew Salter prevented Durham accelerating too quickly before lunch.
Glamorgan reached 37-1 by tea, but the game exploded into life in the closing stages as Aneurin Donald hit 28 off 17 balls, Colin Ingram smashed 42 off 31 deliveries, and Chris Cooke 31 off 20.
Harding's mature display under pressure kept Durham's hopes alive deep into the last hour as both sides strove for their first win of the season.
But Selman, who had never hit a professional six before this innings, took on the responsibility as he cleared the ropes twice with the first two balls of the last over before running a two to complete the chase.
Glamorgan batsman Nick Selman told BBC Wales Sport:
"It was good to get a win and to bat that well puts us in good stead in the future, everyone played a role and it was good to get over the line.
"We wanted to keep wickets in hand, then play it as a one-dayer with a game plan of right-handers coming in against the spin, me and Chris Cooke played well to get it that deep and to finish it off was great.
"The boys reminded me I'd never hit a six so it was good to clear the fence and whack a few."
Durham captain Paul Collingwood told BBC Newcastle:
"We could have batted longer and batted for the draw but the position we're in [with a points deduction], if something special's going to happen this year we have to take the odd risk.
"We knew we'd have to give them a chance, and for a game to go down to the last over with all three results possible.
"It was a good game - unfortunately we came off on the wrong end of it but there's no shame in trying to win matches."
Nick Selman's century took Glamorgan to an unlikely three-wicket win over Durham in a dramatic finish in Swansea.