Steve Shapiro , left, and Michael B. Kimberly, a lawyer at Mayer Brown. (Linda Davidson/The Washington Post)

Steve Shapiro recently pulled his first all-nighter in years.

He worked until about 1 a.m. last month on an assignment for a class at American University’s Washington College of Law, where he is a first-semester 1L. From then until dawn, he pored over his brief due at the U.S. Supreme Court, where his battle against Maryland’s often-criticized gerrymandered congressional districts will be heard this week in a case that bears his name.

At age 55, Shapiro is not the typical law school newbie; he’s more often mistaken for a professor. It was his decades-long fight with Maryland’s political leadership over redistricting that, in part, fueled his decision to leave his job as a career federal employee and enroll full time in law school.

Before he ever took his first law class, he served as his own lawyer, filing the original complaint in what is now called Shapiro v. McManus and a subsequent appeal after losing the first round.

“With each brief, I got a little bit better at it,” Shapiro said in a recent interview in the school’s law library. Still, if he had known what he’s learned in just two months of law school, “I could have made them better.”

Shapiro now has a seasoned lawyer specializing in Supreme Court practice at his side. They will argue a narrow procedural issue Wednesday in the hope of keeping Shapiro’s lawsuit alive. If they succeed, they would still face an uphill battle on his bigger point: that partisan gerrymandering is a threat to an individual’s constitutional rights.

Judges and commentators have conceded that, during Maryland’s 2011 reapportionment, the state’s Democratic leadership put on a master class in manipulating district lines for maximum effect. Democratic officials stated plainly that their goal was to make seven of the state’s eight congressional districts safe for Democratic candidates — as opposed to six from the previous redistricting. And they succeeded.

But is that a matter for the courts, or is it just politics?

More than a decade ago, the justices of the Supreme Court took a hard look at the way politicians bend, tweak and manipulate electoral boundaries to protect themselves and punish their enemies — and threw up their hands.

At the time, Justice Antonin Scalia acknowledged in a case called Vieth v. Jubelirer that the court had long before held out the possibility that partisan gerrymandering could be so severe that it would violate the Constitution’s protection of equal representation. But “18 years of essentially pointless litigation” convinced Scalia and others on the court that it was impossible for judges to come up with a test to decide when partisan gerrymandering — as opposed to racial gerrymandering — went too far.

Shapiro, a Democratic activist in Montgomery County, would like to give the court another chance.

But his suit was stopped last year before it got to first base. Although most redistricting challenges are supposed to be heard by a three-judge panel, a single federal district judge dismissed Shapiro’s case.

The judge cited a rule by the U.S. Court of Appeals for the 4th Circuit, which covers Maryland and Virginia, giving district judges greater discretion to dismiss cases in a way that Shapiro claims is unique in other federal courts and contrary to Supreme Court precedent.

Even as Shapiro and others have repeatedly failed in their legal challenges to Maryland’s congressional boundaries, the district map has been singled out for its creativity.

The 3rd Congressional District, now held by Democratic Rep. John Sarbanes, has been called one of the most gerrymandered in the nation, roping together voters in Silver Spring, northern Montgomery County, Columbia, Annapolis, the city of Baltimore, and Baltimore County. U.S. Circuit Judge Paul V. Niemeyer likened it to a “broken-winged pterodactyl, lying prostrate across the center of the state.” It has also been compared to a blood splatter at a crime scene.

Nevertheless, Niemeyer was part of a unanimous three-judge panel in a case separate from Shapiro’s that found the redistricting did not discriminate racially and noted the ruling in the 2004 Vieth case that partisan gerrymandering seems beyond the court’s reach.

Shapiro lives in the 8th Congressional District, which starts in the corner of Maryland’s westernmost border with the District of Columbia and roams through Montgomery, Prince George’s, Carroll and Frederick counties before ending at the Mason-Dixon line separating the state from Pennsylvania.

Even U.S. District Judge James K. Bredar, who dismissed Shapiro’s suit, said he had a point.

“It may well be that the 4th, 6th, 7th and 8th congressional districts, which are at issue in this case, fail to provide fair and effective representation for all citizens,” Bredar wrote. But he, too, cited Supreme Court precedent: “The power to address plaintiffs’ concerns thus lies not with the judiciary but rather with the state of Maryland and the United States Congress.”

In August, Maryland Gov. Larry Hogan (R) named a commission to examine ways to make redistricting fairer by turning the power to draw congressional boundaries over to a nonpartisan independent panel. Such a proposal would have to win approval in the state’s General Assembly, where Democrats — who have promised to resist the plan — hold large majorities in both chambers.

If the Supreme Court agrees with Shapiro that his case should be heard by a three-judge panel, it would provide another case to get the partisan gerrymandering issue back before the justices.

Shapiro’s ultimate hope lies with Justice Anthony M. Kennedy.

In the Vieth case, Kennedy agreed that the challenge to a redistricting plan in Pennsylvania should fail, but he did not join Scalia in saying all such cases are doomed.

The case did not require that the court “bar all future claims of injury from a partisan gerrymander,” Kennedy wrote, in what Scalia labeled a “never-say-never” concurring opinion.

“First Amendment concerns arise where a state enacts a law that has the purpose and effect of subjecting a group of voters or their party to disfavored treatment by reason of their views,” Kennedy wrote.

That is what happened in Maryland, according to Shapiro and Michael B. Kimberly, the Supreme Court practitioner he brought on board.

Shapiro turned to Kimberly after losing the appeal at the 4th Circuit.

“I read in a magazine how much your chances improved of the [Supreme] Court taking your petition” if you’re represented by someone who regularly argues before it, Shapiro said. He added: “And how much better a chance you’d have if you have any attorney representing you.”

Shapiro began making calls to some of Washington’s prestigious law firms.

Shapiro “used to play softball with the partner in the office next to me,” said Kimberly, an associate at Mayer Brown. The partner, Evan Tager, took Shapiro’s case next door. In a matter of hours, the deal was struck.

“He is an enterprising man,” Kimberly said of Shapiro. “He is much more hands-on than the average client. Understandably — it’s his case.”

Like Shapiro, Kimberly is also a Democrat. They acknowledge that if the suit is successful, it is Maryland’s Republicans who stand to gain. Shapiro recruited Republicans Maria B. Pycha of Baltimore County and O. John Benisek, a tea party activist in Washington County, to join him in the challenge.

“That’s one of the things I love about this case,” Kimberly said. “Your own ideology shouldn’t make a difference.”