The 2016 presidential contest was awash with charges that the fix was in: Republican Donald Trump repeatedly claimed that the election was rigged against him, while Democrats accused the Russians of stacking the odds in Trump's favor.

Less attention was paid to manipulation that occurred not during the presidential race, but before it — in the drawing of lines for hundreds of U.S. and state legislative seats. The result, according to an Associated Press analysis: Republicans had a real advantage.

The AP scrutinized the outcomes of all 435 U.S. House races and about 4,700 state House and Assembly seats up for election last year using a new statistical method of calculating partisan advantage designed to detect potential political gerrymandering.

This chart shows “efficiency gap” measurements of congressional races for most populous U.S. states.

The analysis found four times as many states with Republican-skewed state House or Assembly districts than Democratic ones. Among the two dozen most populated states that determine the vast majority of Congress, there were nearly three times as many with Republican-tilted U.S. House districts.

Traditional battlegrounds such as Wisconsin, Michigan, North Carolina, Pennsylvania, Florida and Virginia were among those with significant Republican advantages in their U.S. or state House races. All had districts drawn by Republicans after the last census in 2010.

The AP analysis also found that Republicans won as many as 22 additional U.S. House seats over what would have been expected based on the average vote share in congressional districts across the country. That helped provide the GOP with a comfortable majority that stood at 241-194 over Democrats after the 2016 elections — a 10 percentage point margin in seats, even though Republican candidates received just 1 percentage point more total votes nationwide.

The efficiency gap

A separate statistical analysis conducted for the AP by the Princeton University Gerrymandering Project found the extreme Republican advantages in some states were no fluke. The Republican edge in Michigan's state House districts had only a 1-in-16,000 probability of occurring by chance; in Wisconsin's Assembly districts, there was a mere 1-in-60,000 likelihood of it happening randomly, the analysis found.

The AP's analysis was based on an "efficiency gap" formula developed by University of Chicago law professor Nick Stephanopoulos and Eric McGhee, a researcher at the nonpartisan Public Policy Institute of California. Their mathematical model was cited last fall as "corroborative evidence" by a federal appeals court panel that struck down Wisconsin's Assembly districts as an intentional partisan gerrymander in violation of Democratic voters' rights to representation.

Although judges have commonly struck down districts because of unequal populations or racial gerrymandering, the courts until now have been reluctant to define exactly when partisan map manipulation crosses the line and becomes unconstitutional. The U.S. Supreme Court has agreed to hear arguments on the Wisconsin case this fall. If upheld, it could dramatically change the way legislative districts are drawn across the U.S. — just in advance of the next round of redistricting after the 2020 Census.

'Most extreme gerrymanders'

Stephanopoulos and McGhee computed efficiency gaps for four decades of congressional and state House races starting in 1972, concluding the pro-Republican maps enacted after the 2010 Census resulted in "the most extreme gerrymanders in modern history."

The efficiency gap formula compares the statewide average share of the vote a party receives in each district with the statewide percentage of seats it wins, taking into account a common political expectation: For each 1 percentage point gain in its statewide vote share, a party normally increases its seat share by 2 percentage points.

The AP used their method to calculate efficiency gaps for all states that held partisan House or Assembly elections for all of their districts in 2016.

Last fall, Michigan voters statewide split their ballots essentially 50-50 between Republican and Democratic state House candidates. Yet Republicans won 57 percent of the House seats, claiming 63 seats to the Democrats' 47. That amounted to an efficiency gap of 10.3 percent favoring Republicans, one of the highest advantages among all states.

Republicans controlled both Michigan legislative chambers and the governor's office when the maps were redrawn in 2011. The Michigan House redistricting effort was led by then-state Rep. Pete Lund, who denied gerrymandering districts to favor Republicans.

"The Democrats don't know how to run campaigns; they're horrible at it," he said.

In addition to Michigan, the analysis found a significant Republican tilt in South Dakota, Wisconsin and Florida, all of which had a Republican-controlled redistricting process after the 2010 Census.

This map, among the exhibits submitted with a lawsuit challenging Wisconsin's 2011 legislative map, shows the differences in legislative districts and representation under different scenarios, including a plan proposed in the lawsuit applied to 2012 election results.

Some advantages for Democrats

Democrats had high efficiency gap scores in Colorado and Nevada, two places where they won state House majorities in 2016 even though Republican candidates received more total statewide votes. Colorado's map was drawn by a Democratic-dominated commission that Republicans criticized as "politically vindictive." Nevada's districts were decided by a court, but Republicans complained at the time that they appeared more favorable to Democrats.

The AP also calculated efficiency gap scores for U.S. House elections, translating those into estimates of extra seats won because of partisan advantages.

In Pennsylvania, Republicans won 13 of the 18 congressional seats last year, three more than would be expected based on the party's vote share, according to the AP analysis.

"There's one answer for that, one word: gerrymander," said Terry Madonna, director of the Center for Politics and Public Affairs at Franklin & Marshall College in Lancaster, Pennsylvania.

In Texas, Republicans gained nearly four excess congressional seats compared to projections from a typical votes-to-seats ratio, according to the AP's analysis. The efficiency gap scores show Republicans picked up at least two excess seats each in Michigan and North Carolina.

One of the largest Democratic congressional advantages was in Maryland, where Democrats controlled redistricting.

The national Republican State Leadership Committee, the force behind the party's surge in state legislative elections, attributes its victories to candidates who better represent their communities.

For Democrats to complain of gerrymandering is "pure nonsense," said Matt Walter, the Republican committee's president.

"That's just a baseless supposition to blame that all on line-drawing," he said.

Associated Press data journalist Meghan Hoyer contributed to this report.

Outbrain