
Despite appearing in a mere three short stories written by
Edgar Allan Poe, C. Auguste Dupin is generally acknowledged as the first detective in fiction, and the prototype for the likes of
Sherlock Holmes by
Arthur Conan Doyle and
Hercule Poirot by
Agatha Christie. many tropes that would later become commonplace in detective fiction first appeared in Poe's stories: the eccentric but brilliant detective; the bumbling police; the first-person narration by a friend. Poe's Dupin stories also are the first where the detective announces his solution and then explains the reasoning leading to it.
Read all three stories free online:
"The Murders in The Rue Morgue" (1841)
"The Mystery of Marie Roget" (1842)
"The Purloined Letter" (1844)
Note: The book
The Beautiful Cigar Girl: Mary Rogers, Edgar Allan Poe, and the Invention of Murder 
details how author Poe wrote "The Mystery of Marie Roget" as an attempt to solve a real-life unsolved crime.
Further Reading:
The Complete Stories (Everyman's Library) by Edgar Allan Poe
Complete Stories and Poems of Edgar Allan Poe
More detectives:
CHARLIE CHAN by Earl Derr Biggers
PHILO VANCE by S.S. Van Dine
ALBERT CAMPION by Margery Allingham
DR. GIDEON FELL by John Dickson Carr
NERO WOLFE and ARCHIE GOODWIN by Rex Stout
150 Mystery Series: 1841-2010
Murderous Beginnings: 40 Detective Fiction Firsts