a.k.a. black hat search engine optimization, black hat hacker
The term "black hat" originated from search engine optimization lingo and generally means to seek to exploit the weaknesses of search engines in order to boost a site's ranking on results pages. These techniques often rely on deception, redirection, and other artificial means to generate results, see the example below.
The term black hat morphed into also meaning a malicious hacker who commits illegal acts, as in a "black hat hacker." The Oxford English Dictionary cites the phrase's earliest usage as 1990: "The idea of the 'pick one from three' is so the black hats can't tell which challenge you're responding to, and thus can't build a table from observation."
Black hat hacker specifically comes from an earlier meaning of black hat, "a villain or bad guy in a story, especially in a Western" from the late 1950s. Once it was easy to tell the heroes from the villains in the television Westerns: The white hats were the good guys and the black hats were the bad guys. By that token, a "white hat hacker" is a well-meaning hacker who hacks for a good cause or to aid a company, organization, or government without causing harm.
In a search engine optimization example, a black hat SEO specialist might create hundreds of pages filled with keyword-rich gibberish for search engines to find and parse, or they might post meaningless comments on hundreds of blogs, all linking back to the main Web site. It can be tempting to employ black hat techniques to promote Web sites, especially when it produces dramatic short-term results. However, search engines always attempt to out-think the black hat SEOs, and the results are therefore short term. In fact, using deceptive techniques can get you banned from search engines and permanently damange your ranking.