A snob was originally (late 18th century) slang for cobbler or shoemaker, ie a very ordinary person. In Cambridge University slang at roughly the same time a snob was a townsman, as opposed to a gownsman, or student. Jonathon Green in his Dictionary of Slang says that this Cambridge-specific use may have referred to tradesmen trying to flatter the students to get their business.
The word was popularised by William Thackeray in his Book of Snobs (1848). Thackeray used the word snob to mean someone who wishes to associate with people of a higher social status and who wishes to be regarded as a person of social importance (he also coined the word snob-land). This meaning overlaps with another meaning of snob, as given in the OED: "A person who despises those whom he or she considers to be inferior in rank, attainment, or taste".