The genre started way back in the 19th century with masters of suspense like Edgar Allan Poe and Sir Arthur Conan Doyle, both of whom wrote stories about sleuths who use the power of their intellect to solve crime capers.
Detective fiction is usually considered popular fiction. Writers like P.D. James and Patricia Highsmith carry on the tradition that was started way back when. There's also a sub-genre of detective fiction called hard-boiled detective fiction. Hard-boiled detectives were rough-and-tumble antiheroes who relied on fisticuffs in addition to their wits. The fedoras didn't hurt, either, especially when it came to attracting femme fatales. Think of Dashiell Hammett's Sam Spade or Raymond Chandler's Philip Marlowe.