Gerrymandering is the act of redrawing the lines of a congressional district to give one political party a voting advantage over another. Technically, gerrymandering is illegal, but it's hard to prove. While both political parties deny that they gerrymander, it does tend to happen; and after every redistricting effort, the courts hear numerous cases of alleged gerrymandering.
Once every ten years, following the U.S. census, the 435 members of the U.S. House of Representatives are reapportioned based on the population of each state, relative to other states. (As the population shifts from one part of the country to another, some states will gain representatives while others lose them.) Each state legislature redistricts their state into the appropriate numbers of congressional districts, with the goal of making sure that each district has very close to the same population as the other districts.
Because a single party almost always controls a state legislature, of course it would be in that party's best interest to try to draw the district lines so their party will win or retain more seats in the House of Representatives than the opposition party.
Gerrymandering can take on a few different forms. The controlling party may try to force the opposition party into as few districts as possible. Or they may try to dilute the opposition across many districts so that they won't have a voting majority in any of them. Or they may draw strangely shaped districts to split opposition votes or combine the votes of the party in power. Sometimes, these borders are designed to split the votes of ethnic, racial, religious, or other class groups.
The term gerrymandering came to be thanks to Elbridge Gerry, the governor of Massachusetts from 1810 to 1812. During his tenure, Governor Gerry signed a bill that redistricted his state to overwhelmingly benefit his party (the Republicans), much to the dismay of the opposition party (the Federalists). One of the congressional districts was said to be shaped like a salamander, to which one Federalist reportedly said: No, it's a gerrymander.
Soon, newspapers were printing editorial cartoons with the term gerrymander, and the word became commonly known.
Gerrymandering has been addressed by both Congress and the Supreme Court:
In 1842, Congress passed the Reapportionment Act, which required congressional districts to be contiguous and compact.
In 1962, the Supreme Court ruled that districts must and have reasonable borders and must represent the population appropriately.
In 1985, the Supreme Court ruled that manipulating district borders for political advantage is unconstitutional.
After every census, many redistricting plans are challenged in the courts, often with the minority party accusing the majority party of political gerrymandering or a special interest group accusing the government of racial gerrymandering.