WASHINGTON — When President Barack Obama was in the White House, Ken Cuccinelli accused the executive branch of appointing key officials by circumventing the U.S. Senate.

It was 2013 and Cuccinelli, then Virginia’s Republican attorney general, joined other states in submitting a “friend of the court” brief to the U.S. Supreme Court that criticized Obama, whom they argued “defied his coordinate branch’s exercise of its constitutional prerogative” by appointing members to the National Labor Relations Board “without trying to seek the Senate’s approval.”

The Supreme Court sided with Obama’s critics in that case, ruling unanimously in 2014 that Obama had overstepped when he declared the Senate “in recess” and therefore unable to act on his nominations, The Washington Post reported at the time. The Senate was holding perfunctory sessions every three days in an attempt to block nominations.

Cuccinelli and his allies argued that bypassing the Senate on important nominations hurt states’ ability to weigh in on federal appointments that require Senate confirmation.

“The Senate must be able to use the advice-and-consent process to protect state prerogatives and individual liberty in these circumstances, and the President must not be able to circumvent the process through recess appointments,” they wrote.

Cuccinelli now finds himself on the losing side of a case over executive branch appointments after a federal judge ruled Sunday that he was unlawfully appointed by President Donald Trump to head a federal immigration agency.

The decision made waves, in part because it invalidates two immigration directives issued by Cuccinelli that sought to restrict legal immigration. One of those directives limited the amount of time for asylum seekers to consult with lawyers after entering the United States; the other limited the extensions granted to asylum seekers.

The former Virginia attorney general is also a political lightning rod, and the court’s rebuke was viewed by his critics as a major victory against one of Trump’s top immigration officials. Cuccinelli told Fox News, “You can expect an appeal, and we’ll take intermediate steps to avoid any challenges. But it doesn’t affect anything we’re doing going forward.”

A Department of Homeland Security spokesperson said in a statement, “We obviously disagree with the court’s decision and will be looking closely at the decision.”

Cuccinelli’s appointment was deemed unlawful because his June 2019 hire violated the Federal Vacancies Reform Act, a law that stipulates who can fill jobs that require Senate confirmation until a permanent replacement is appointed.

Judge Randolph D. Moss of the U.S. District Court for the District of Columbia ruled that Cuccinelli hadn’t met the law’s requirements because he hadn’t served as “first assistant” to the vacant office, nor had he served in a senior position in the agency for at least 90 days prior to his appointment as acting director of U.S. Citizenship and Immigration Services.

Cuccinelli has not been nominated by Trump to lead the USCIS or for his position as the No. 2 at DHS, a role he also holds in an acting capacity. DHS’ website lists Cuccinelli as the “senior official performing the duties of the deputy secretary.”

The legal issues at play in the Obama case and the Cuccinelli case are different, said Jonathan Adler, a professor at the Case Western Reserve University School of Law. The Obama case was “really about circumventing Congress,” while the Cuccinelli case involves an apparent failure to comply with congressional instructions. He called that difference “subtle” but important.

“I don’t think the Trump administration’s effort to put Cuccinelli into that position is perhaps as aggressive as the Obama administration’s approach was to the NLRB, but — and this is a big qualifier — across the board, the Trump administration has shown a fair amount of aggressiveness on the willingness to rely upon [acting officials] generally as a way of filling positions,” Adler said.