Media playback is not supported on this device
Leicester's Selby, runner-up in 2007, was 10-5 behind but won 10 of the next 12 frames for a 15-12 lead.
Five-time champion O'Sullivan, who had never lost a world final, reduced the deficit to 15-14, only for Selby to win the next three frames.
Age: 30
Nickname: The Jester from Leicester
Turned pro: 1999
Ranking titles: World Championship 2014, UK Championship 2012, Shanghai Masters 2011, Welsh Open 2008
Non-ranking titles: Masters 2008, 2010, 2013
His victory means he returns to the top of the world rankings and leaves O'Sullivan two behind Stephen Hendry's record tally of seven world titles.
Selby dedicated his win to his late father, who died when he was 16.
"To beat Ronnie in the final to win my first world title is a dream come true," he added:
O'Sullivan said: "I tried my hardest but he was just too good,"
Selby, 30, is £300,000 richer for his Crucible triumph and is the ninth player to win the Triple Crown, having won three Masters titles and a UK Championship.
Selby looked jaded on Sunday following his epic semi-final against Neil Robertson but managed to win the final two frames to stay within three of O'Sullivan, who wrapped up his last-four encounter against Barry Hawkins with a session to spare.
He then won five of the six frames in Monday's opening session to drag his rival into unfamiliar territory, O'Sullivan having never before trailed heading into the final session of a Crucible final.
Selby made breaks of 55, 52 and 74 - his highest of the match so far - to level the contest at 10-10 before winning a tense 21st frame to lead for the first time.
O'Sullivan retook the lead after the mid-session interval, winning an error-strewn frame courtesy of a run of 50, but missed a simple pink into the middle pocket to clinch the frame after deciding to play it with pace.
Selby duly cleared up before punching the air and ramming his cue into the ground in a mixture of relief and elation.
Media playback is not supported on this device
Eight frames were scheduled for the session but it was a measure of the attritional nature of the action that they could only fit six in before the interval.
O'Sullivan won the first frame of the evening session with a fluent break of 100, his third century of the match, to level at 12-12, but Selby won a 28-minute frame to restore his advantage before opening up a two-frame lead for the first time.
Selby compiled a break of 56 to increase his lead to three frames before the mid-session interval, his run of take 10 of the last 12 frames.
O'Sullivan started well after the restart, rattling in breaks of 30 and 49 to reduce the gap to two frames. He then potted a magnificent yellow down the cushion before clearing up the rest of the balls to make it 15-14.
But Selby reacted brilliantly, knocking in a break of 127, his first century of the match, before a run of 87 to move within a frame of victory.
O'Sullivan had chances in the next frame but Selby pounced to complete a nerve-jangling clearance after his opponent missed the final red.She beat the 21st seed 4-6 6-4 8-6 in the fourth round, in a match that lasted three hours and four minutes.
"It was mentally, emotionally and physically draining," Konta said.
At 24 years old, Konta is ranked 47th in the world.
Her next opponent will either be 15th seed Madison Keys, or China's Shuai Zhang.
The 'Grand Slam' tournaments are the four most important annual tennis competitions. Players travel from around the world to take part in them.
They include the Australian Open, US Open, Roland Garros, and Wimbledon.
The last British woman to play in the quarter-finals of a Grand Slam was Jo Durie, at Wimbledon in 1984.Jake Morrison triumphed over Lord Storey in Wavertree as the Liberal Democrats - who held power only two years ago - took heavy losses.
Another high profile Lib Dem casualty was former education spokesman Paul Clein, who said his defeat was not "a reflection on local candidates".
Labour took 12 of the 14 Lib Dem seats being contested.
Mr Morrison, a healthcare assistant at the Royal Liverpool Hospital, said: "It's absolutely fantastic - I'm over the moon.
"Obviously I hope to follow in some of Mike's (Lord Storey's) footsteps. He's been a councillor for over 38 years and