In the American system, the biggest target of gerrymandering is the House of Representatives. The members of the Senate are elected by the entire state and thus are exempt from boundary redrawing. The Constitution requires that a census of the population be taken every ten years, and that the seats in the House be reapportioned (and their districts redrawn) as necessary.
The Constitution leaves open the question of who should draw the electoral boundaries for federal representatives within a state. Article One dictates that the state legislatures may choose the “time, place, and manner” of elections, and “manner” is interpreted to include the drawing of district lines. At the same time, the Constitution also says that Congress may “at any time make a law or alter such Regulations.” With this ambiguity in the Constitution, both the state and federal government have historically competed for legal power over elections, including the power to gerrymander.
The picture became more complicated with the passage of the Fourteenth Amendment following the end of the American Civil War. While the Amendment does not explicitly mention voting rights (aside from revoking the Three-Fifths Compromise), it sets out the wide-ranging principle that states may not limit the rights or privileges associated with citizenship, particularly on the basis of race. Since the passage of the Fourteenth Amendment, the Supreme Court has struck down attempts to gerrymander House districts based on race. This has led to some strained judicial arguments: in 2017, after drawing a particularly egregious House boundary that packed overwhelming groups of black citizens in a few districts to limit the impact of their vote, the state of North Carolina argued that it had done so because the voters were black (which would be illegal) but because they were Democrats (which, the Court had ruled, was not a reason to strike down the districts).
Ultimately, the legal consensus on gerrymandering in the US is still evolving. The Supreme Court has expressed concern that gerrymandering violates democratic principles, but because the Constitution is silent on the matter the Court has not established a process for reviewing or challenging partisan districts. In fact, in the most recent gerrymandering case (Vieth v Jubilirer), the Court agreed that the districts were illegally drawn with an intent to influence results, but argued that the Supreme Court was not the right branch of government to correct the issue. In 2017, the Supreme Court agreed to hear a case challenging districts in the state of Wisconsin, which is still pending.