The book, published by Jonathan Cape on 13 April 1953, was written by Fleming at his Goldeneye estate in Jamaica while awaiting his marriage.
The initial run of 4,728 copies sold out in less than a month and when further editions also flew off the shelves, publisher Cape offered Fleming a three-book deal.
It went under the hammer at Lyon & Turnbull's sale of rare books, maps and manuscripts in the Scottish capital today valued at £12,000 to £18,000.
It was bought by an anonymous online bidder for more than three times the upper estimate, after competition from a rival telephone bidder.
Cathy Marsden, book specialist at Lyon & Turnbull, said: "We are delighted with the sum for this rare first edition of Casino Royale, which we can confirm is a new world record for the title.
"The work was published in a run of just over 4,500 copies: a figure which seems large, but pales in comparison to the posthumously published The Man With the Golden Gun, which commanded a print run of 82,000 copies.
"Today, first edition copies of Casino Royale complete with dust-jacket are relatively rare - and inscribed copies are even more unusual."
On one wartime trip to neutral Portugal, Fleming had gone to a casino in Lisbon where he claimed to have been "cleaned out" by a German agent.
Casino Royale was later adapted into a 1967 film starring David Niven as Bond and a 2006 version featuring Daniel Craig in the role.
The rare book features on the reverse of the dust-jacket, the description: "Ian Fleming is 44. Like his brother Peter, the more famous author, he was educated at Eton."
Peter Fleming is today invariably described as "the older brother of Ian Fleming".
The Casino Royale book was among a collection of Bond first editions that made a total of £97,000 in the Lyon & Turnbull sale.
A rare first edition of Fleming's Bond 1954 novel Live and Let Die, given to one of Fleming's fellow NID members, made £30,000 - six times its pre-sale estimate of £3,000-5,000. The book was inscribed by Fleming himself "to Robert Bartlett from the Author 1954".
A very rare surviving copy of The Man with the Golden Gun - one of only around 940 true first issues with a golden foil gun embossed onto the upper cover - was sold for £4,625, while a rare edition of Diamonds are Forever, estimated at £600-800, eventually made £2,375.
Miss Marsden said: "This is a great result with two Bond novels selling for large sums. We had interest from around the world with bidders on the telephone, in the room and online.
"First editions of Fleming's Bond novels are highly sought after, particularly those published in the 1950s, prior to the first James Bond film release, Dr No, in 1962."