Selby and O'Brien will begin their match at the Crucible Theatre in Sheffield, northern England, on Saturday's opening day.
O'Brien, 45, beat England's Dave Gilbert 10-9 at Sheffield's Ponds Forge sports centre, with the final frame lasting an extraordinary two hours, three minutes and 41 seconds.
That surpassed by a distance the previous record of one hour, 40 minutes and 24 seconds set by Alan McManus and Barry Pinches at the 2015 Ruhr Open.
"Obviously in an ideal world you win a bit quicker than that," said O'Brien after his marathon match.
"The balls went scrappy in the colours and I was so tired, double-checking everything and I'm so, so relieved," he added before the draw was made Thursday.
O'Brien has been handed just about the toughest draw possible given English cueman Selby, bidding for a third world title after also winning snooker's most important tournament in 2014, took the China Open title earlier this month.
Selby and O'Brien will begin their match at the Crucible Theatre in Sheffield, northern England, on Saturday's opening day, with the 17-day tournament due to finish on May 1.
Meanwhile five-times world champion and fans' favourite Ronnie O'Sullivan faces Gary Wilson, one of five tournament debutants this year, in an all-English first-round clash.
One of the highlights of the first round is the all Chinese encounter between Ding Junhui, last year's runner-up, and 19-year-old Zhou Yuelong.
An even younger Chinese player, 17-year-old Yan Bingtao, is up against 2005 world champion Shaun Murphy.
Elsewhere in the draw, China's Xiao Guodong plays 16th seed Ryan Day of Wales.
No player from China has yet won the world title but their growing strength as a snooker nation was underlined by the presence in the first-round draw of Liang Wenbo, who will play England's Stuart Carrington.
An intriguing clash sees Australia's Neil Robertson, the 2010 world champion, begin his quest for a second Crucible crown against Thailand's Noppon Saengkham.
Four-time champion John Higgins faces Martin Gould while at least one former world champion will be knocked out in the first round when 2015 title-winner Stuart Bingham plays Peter Ebdon, who took the title in 2002.
This year marks the 40th anniversary of the first World Championship staged at the Crucible, now regarded as the 'home of snooker'.
Friday will see the Crucible play host to a parade of past winners, with Wales's Mark Williams -- beaten in the final round of qualifying -- the only living former world champion not expected to take part.
The parade will include Graeme Dott, the 2006 world champion, after the Scot secured his place in the draw with a 10-8 win over Jamie Jones in final qualifying.
But Dott said he too might not have turned up if he'd been beaten by Jones.
"If I had lost I don't know if I could bear it, being there when you're not in the tournament," admitted Dott, who has been drawn against two-time runner-up Ali Carter.
Draw for the first round of the World Championship (x denotes seed):
Mark Selby (ENG x1) v Fergal O'Brien (IRL)
Ryan Day (WAL x16) v Xiao Guodong (CHN)
Neil Robertson (AUS x9) v Noppon Saengkham (THA)
Marco Fu (HKG x8) v Luca Brecel (BEL)
Shaun Murphy (ENG x5) v Yan Bingtao (CHN)
Ronnie O'Sullivan (ENG x12) v Gary Wilson (ENG)
Liang Wenbo (CHN x13) v Stuart Carrington (ENG)
Ding Junhui (CHN x4) v Zhou Yuelong (CHN)
Stuart Bingham (ENG x3) v Peter Ebdon (ENG)
Kyren Wilson (ENG x14) v David Grace (ENG)
Mark Allen (NIR x11) v Jimmy Robertson (ENG)
John Higgins (SCO x6) v Martin Gould (ENG)
Barry Hawkins (ENG x7) v Tom Ford (ENG)
Ali Carter (ENG x10) v Graeme Dott (SCO)
Anthony McGill (SCO x15) v Stephen Maguire (SCO)
Judd Trump (ENG x2) v Rory McLeod (ENG)