(CNN) Chief Justice John Roberts' announcement last week forbidding -- at least for now -- a citizenship question on the 2020 census echoed his surprise affirmation of the Affordable Care Act in 2012.

In both instances, Roberts first detailed all the reasons why the Supreme Court might rule the opposite, before he suddenly revealed in the hushed courtroom setting that he had split from his conservative brethren and sided with the four liberal justices in a politically charged dispute.

For years, Roberts' 2012 Obamacare vote stood out. But the 5-4 census case and other moves in the recently completed session demonstrated Roberts' new variability in fraught cases. The man in the center chair is now at the ideological middle of the bench and plainly more willing to break from his customary allies on the right to forge compromises with the left, particularly in cases with an outsized national impact.

The lesson is especially apt as another broad-scale challenge to the Obamacare law, set to be heard in a New Orleans-based US appeals court next week, appears destined for the justices.

The census case itself could return soon to test Roberts, the nation's 17th chief justice and the first in more than 75 years to sit at the helm and also at the middle of the ideological spectrum.

President Donald Trump said on Monday that the administration was considering delaying the 2020 census so that it could ensure the addition of a question about citizenship status. Department of Justice lawyers on Monday asked a US judge in Maryland to extend a deadline for the government's filing in a related matter for a day, though the administration had earlier told federal judges that it needed to begin printing census forms by July 1.

Even as much is yet to be determined about the upcoming decennial census, this much is plain: The ultimate resolution, just as it was for Obamacare in 2012 and likely will be again, will be controlled by Roberts, now age 64, and a legal rationale marked by twists and compromises.

Roberts speaks

The population count from the census becomes the basis for apportioning members of the US House of Representatives and for determining state political districts, as well as for allocating federal, state and local funding. New York and other challengers to the citizenship inquiry say it would lead to a lower response rate and an undercount of Hispanic and noncitizen households. The result would be a loss of federal funding and political power for mainly Democratic states.

Last Thursday, under the gilded courtroom ceiling, Roberts spent about half of his 15-minute announcement rejecting the challenge, based on the Constitution's enumeration clause and the federal Administrative Procedure Act, to the Department of Commerce's plan. Roberts said judges must broadly defer to Commerce Secretary Wilbur Ross's proposal for the census and his determination "that reinstating a citizenship question was worth the risk of a potentially lower response rate."

In the portion of Roberts' opinion joined by fellow conservatives, he called Ross' decision "reasonable," writing that "it is not for us to ask whether his decision was 'the best one possible' or even 'better than the alternatives.'"

With lawyers from the US Solicitor General's office who had made the case for the Commerce Secretary seated at a table just below the bench, Roberts then made an abrupt turn to what Ross had done wrong: he contrived his specific justification for the question. In Roberts' 29-page written opinion, the chief justice did not rebuff Ross until page 23.

Joined at this point by the liberal justices, Roberts noted that the agency said it was adding the question for the sole reason of obtaining citizenship data to better enforce the Voting Rights Act.

Clearing his throat as he continued reading from a prepared text, Roberts said the lower-court evidence revealed a "mismatch" between the decision Ross made and the rationale he provided. In his written opinion, Roberts deemed the VRA justification "contrived" and wrote that "if judicial review is to be more than an empty ritual, it must demand something better than the explanation offered for the action taken in this case."

Roberts said the agency should have another chance to explain the grounds for a citizenship question and returned the case for further proceedings.

Back in 2012 in the Obamacare dispute, Roberts' bench announcement unspooled in similar fashion. In the first half of his statement regarding the individual insurance requirement that was the Obamacare linchpin, Roberts emphasized the grounds for its unconstitutionality. He said it exceeded Congress' power to regulate interstate commerce.

But then he suddenly shifted and said, based on congressional taxing power, that the insurance requirement could be upheld. That decision, it turned out, arose from extraordinary Roberts' moves behind the scenes. He changed course multiple times as the justices considered the milestone insurance overhaul signed by President Barack Obama in 2010.

Shielding the Supreme Court from partisanship

Roberts, a 2005 appointee of President George W. Bush, has long voiced a desire to keep the court above partisan politics.

In November, after Trump tried to demean a US district court judge who ruled against the administration by calling him an "Obama judge," Roberts countered in a statement, "We do not have Obama judges or Trump judges, Bush judges or Clinton judges. What we have is an extraordinary group of dedicated judges doing their level best to do equal right to those appearing before them."

That assertion may not be so persuasive to the public, as today Roberts and the other four conservatives, all Republican appointees, often align with GOP interests. The four liberals, who were appointed by Democratic presidents, similarly tilt to the political left.

The justices' alliances were not so neat in earlier decades, when some Republican appointees ended up on the left and some Democratic justices moved right. Until his retirement last year, Justice Anthony Kennedy, named by President Ronald Reagan, often confounded categorization as he supported abortion rights, gay marriage and some affirmative action.

Kennedy was succeeded in 2018 by the more conservative Brett Kavanaugh, solidifying the right-wing of the bench and putting Roberts at the middle and in a new swing-vote position.

As the 2018-19 session demonstrated, when Roberts sides with the liberals, it tends to be with exceedingly narrow reasoning. His moves to the left reflect an effort to try to lower political tensions. Such instincts could matter on abortion rights, which the high court might address in the upcoming session, and they could be determinative on the next round of Obamacare.

Another Obamacare challenge looms

The US Court of Appeals for the 5th Circuit is scheduled to hear an appeal on July 9 of a district court judge's decision that would invalidate the entire Affordable Care Act. Judge Reed O'Connor ruled last December that the whole law must fall because Congress in 2017 lifted the tax penalty tied to the individual insurance requirement.

O'Connor's December 2018 decision threw into jeopardy the individual coverage mandate, along with the law's expansion of Medicaid coverage and protections for people with cancer, diabetes and other pre-existing health conditions.

The Trump administration wants that ruling in Texas v. United States affirmed and, invoking Roberts' compromise opinion from 2012, has argued that with the tax penalty repealed, the individual mandate, and all other interconnected provisions, cannot be grounded in Congress' taxing authority.

If an Obamacare controversy returns to the justices, Roberts may not believe he is out of options. In the most recent term, he maneuvered assiduously among competing interests. He seemed determined to avoid reinforcing Trump's assertion that judges' actions can be fully predicted by an allegiance to the president who appointed them.

And in 2015, when Roberts reinforced his 2012 decision and again voted to uphold the Obamacare law, he wrote, "Congress passed the Affordable Care Act to improve health insurance markets, not to destroy them. If at all possible, we must interpret the Act in a way that is consistent with the former, and avoids the latter."