The justices pose for a portrait at the Supreme Court in Washington.) (Matt McClain/The Washington Post)

The Supreme Court on Friday gave a second chance to a U.S. permanent resident who pleaded guilty to a drug charge and faces deportation because his lawyer gave him bad advice.

Chief Justice John G. Roberts Jr. said Jae Lee’s lawyer was “dead wrong” when he advised his client that accepting a plea deal would get him a shorter sentence in jail but not affect his immigration status. After pleading guilty and receiving a one-year sentence, Lee was transferred to a detention center he learned was for those awaiting deportation.

The decision came as the court began winding down its 2016-17 term. Roberts said the court will dispense with six remaining cases Monday, its scheduled final day. There’s a possibility that the justices deadlocked on some of them before Justice Neil M. Gorsuch filled the ninth seat on the court, and they will be scheduled for reargument.

And the court still must decide on President Trump’s request that it lift the injunctions imposed by two appeals courts and allow his executive order temporarily barring travelers from six mostly Muslim countries and freezing refu­gee entries.

In the deportation case, the question for the Supreme Court was whether Lee should be able to withdraw the plea and take his chances at trial, even though he had no defense to the drug charge and faced almost certain conviction. That would result in the same deportation status as the guilty plea, the government argued.

But the court ruled 6 to 2 that the “almost” in the equation meant Lee’s right to effective legal counsel was violated.

“But for his attorney’s incompetence, Lee would have known that accepting the plea agreement would certainly lead to deportation. Going to trial? Almost certainly,” Roberts wrote.

“If deportation were the ‘determinative issue’ for an individual in plea discussions, as it was for Lee; if that individual had strong connections to this country and no other, as did Lee; and if the consequences of taking a chance at trial were not markedly harsher than pleading, as in this case, that ‘almost’ could make all the difference,” he wrote.

Roberts was joined by Justices Anthony M. Kennedy, Ruth Bader Ginsburg, Stephen G. Breyer, Sonia Sotomayor and Elena Kagan. Justices Clarence Thomas and Samuel A. Alito Jr. dissented, and the case was argued before Gorsuch joined the court.

Thomas repeated his belief that the Sixth Amendment “does not require counsel to provide accurate advice concerning the potential removal consequences of a guilty plea,” repeating the words of an earlier dissent on the subject.

But he, joined by Alito, also said the decision will have “pernicious consequences for the criminal justice system.” The decision “provides no assurance that plea deals negotiated in good faith with guilty defendants will remain final.”

But Roberts said there will be few cases like Lee’s.

He has lived his adult life in the United States, brought to Brooklyn by his parents in 1982 when he was 13, and he has maintained no ties to his native South Korea. He moved to Tennessee, and he’s worked in restaurants in the Memphis area. Roberts noted that Lee is the only family member in the United States who could care for his elderly parents.

Lee began to use the drug ecstasy recreationally, and the government says he became a dealer. When police executed a search warrant in 2009, they found 88 ecstasy pills, over $32,000 in cash and a loaded rifle.

When lawyer Larry Fitzgerald began to negotiate a plea deal, Lee told him his top priority was not to be deported. Fitzgerald told him he should not worry each time Lee inquired about his status. But deportation proceedings began immediately upon his guilty plea.

His lawyer at the Supreme Court, John J. Bursch, said Lee has been in a state jail for close to 7 ½ years as his case has advanced through the courts.

It is Lee v. United States.

Ruling for ex-federal worker

The court ruled for a federal employee who claims his forced retirement was discriminatory, in a case notable because it drew the first dissent authored by Gorsuch, who joined the court in April.

The 7-to-2 decision, written by Ginsburg, did not address the merits of Anthony Perry’s claim that he was forced out at the U.S. Census Bureau. After Perry received notice in 2011 he would be terminated for what Ginsburg called “spotty attendance,” he agreed to a 30-day suspension and early retirement. He later filed a complaint.

The question for the court was where Perry could seek judicial review when an employee’s case asserts rights under both civil service law and federal anti-discrimination law. Such a claim is called a “mixed case.”

Ginsburg cut through a thicket of federal law, procedural rules and court precedents to declare that the answer is federal district court, not the U.S. Court of Appeals for the Federal Circuit, as a lower court had held.

In objecting, Gorsuch showed the tight allegiance he pledged during his confirmation hearings to meticulously following the words of the law. To find in Perry’s favor would require a “tweak” in the law, he wrote.

“If a statute needs repair, there’s a constitutionally prescribed way to do it,” Gorsuch wrote. “It’s called legislation.”

That may be harder than going to court, he said, but requiring a legislative fix “isn’t some bug in the constitutional design: it’s the point of the design, the better to preserve liberty.”

Ginsburg responded: “Perry asks us not to ‘tweak’ the statute but to read it sensibly.”

All except Thomas agreed with Ginsburg’s reading.

The case is Perry v. Merit Systems Protection Board.

Private property rights ruling

The court split 5 to 3 on a long-pending case involving private property rights and whether owners in Wisconsin should have been compensated for a local regulation they said reduced the value of their land.

The case was a fact-specific one brought by the Murr family, who claimed the way local regulators analyzed their holdings decreased its value to such an extent that they were owed compensation. The decision, the family said, stopped them from selling part of the land to raise money to pay for improvements to a cabin on another part.

Kennedy, joined by the court’s liberals, said the value of the land had not really decreased much and proposed a multipart test judges should look to in future cases.

Conservative legal groups objected to the decision, especially the test. It involves, among other things, “the treatment of the land under state and local law; the physical characteristics of the land; and the prospective value of the regulated land.”

Roberts dissented from the opinion, along with Alito and Thomas. He said the result “does not trouble me” because he thought the Murrs could still make good use of the land, which had been two lots the local officials said should be classified as one.

But he said the majority made a complicated formula when a “traditional approach” would do: “State law defines the boundaries of distinct parcels of land, and those boundaries should determine the ‘private property’ at issue in regulatory takings cases.”

The case is Murr v. Wisconsin.