The author was trying to find a publisher for The Cuckoo's Calling, which was eventually released in 2013.
Rowling posted the rejections on Twitter, saying she was doing so to encourage other aspiring writers.
One of the letters, from publishing house Constable & Robinson, says it "could not publish [The Cuckoo's Calling] with commercial success".
The letter goes on to suggest politely that Galbraith "double check in a helpful bookshop" or in the twice yearly "buyer's guide of Bookseller magazine", about who the current publishers of his fiction genre are.
The letter adds "a writers' group or writing course may help" Galbraith to get constructive criticism of his debut crime novel.
The second letter, from Creme de la Crime publishers, explains simply that they have become part of Severn House Publishers and are "unable to accept new submissions at the moment".
Rowling, who has more than seven million Twitter followers, posted them in response to a fan's request for a picture of a rejection letter.
She explained: "The Potter ones are now in a box in my attic, but I could show you Robert Galbraith's?"
The Harry Potter author removed the signatures from the letters because she said she was posting them "for inspiration, not revenge".
"I wasn't going to give up until every single publisher turned me down, but I often feared that would happen," she added.
Author Joanne Harris joined the Twitter discussion, joking that she got so many rejections for her 1999 novel Chocolat that she had "made a sculpture" out of them.
The novel went on to become hugely successful and was made into a film starring Juliette Binoche, Judi Dench and Johnny Depp.
The Cuckoo's Calling was eventually published by Sphere Books, an imprint of Little, Brown & Company.
The book sold about 1,500 copies before Rowling's identity as the author was revealed by the Sunday Times newspaper.
It was Rowling's second novel for adults, having released The Casual Vacancy under her real name in 2012.
The Harry Potter series of books has to date sold more than 400 million copies. The eight film adaptations of the books have been named as the second-highest grossing franchise and film series of all time.
Rowling has also been named as the first female novelist in the world to become a billionaire.
JK Rowling has shared two rejection letters she received for her first novel writing as Robert Galbraith.