The California Legislature wrapped up its work for this session in mid-September, and unlike years past, the group was very productive toward the end.

Lawmakers agreed on a lot of important stuff, much of it aimed at counter-punching against the Trump administration’s untiring efforts to take control of both the executive and legislative branches of the federal government triad.

The Legislature raised the gasoline tax, extended programs designed to convince industries in the state to voluntarily reduce air pollution, and at the end of the session in mid-September took a courageous, controversial stand against federal orders by passing a bill making California an official sanctuary state.

Gov. Jerry Brown had until mid-October to sign bills into law, but he put his name on the sanctuary legislation during the first week of October.

Essentially, the Trump administration’s marching orders are that states are required to spend local resources enforcing federal laws. California and a few other states and cities are refusing to do that, for a variety of reasons.

The Trump administration seems intent on throwing the baby out with the bath water, but every mother knows that’s not how you clean and protect the baby.

President Trump is being backed by the U.S. Department of Justice, with Secretary Jeff Sessions warning cities and states that those who do not follow orders will be punished, mostly by losing federal funding.

The problem for the Trump administration is that many cities and states are pushing back — California being the largest and most politically potent of the bunch — with lawsuits challenging the federal government’s right to tell states what to do. Trump, as a businessman, is accustomed to courtroom battles. He and his companies have been sued thousands of times over the years.

But this is not just about money. It’s about cities and states protecting people and the local economies, which is a key component in the new California sanctuary law.

We’ve reviewed provisions in the new law, and it’s not exactly a thumb-your-nose-at-the-feds deal. For example, the law allows communities to get the federal agents involved when an undocumented immigrant with a felony record has been arrested.

However, the law also bars local governments from forcing the undocumented to spend extra time in jail awaiting the arrival of federal law enforcement officers to take them into custody.

The law is, indeed, controversial, and it is a sure bet that its legality will be challenged in court, either by local critics or the Justice Department, or both.

Trump took a stab at cutting funding to sanctuary cities soon after taking office in January, using his executive-order powers, but the order was quickly blocked by a San Francisco judge. That set the stage for what will surely be a legal battle of epic proportions.

We understand that crossing borders to enter the United States without the proper authorization is illegal. It’s a simple concept. But we also understand that so many who have crossed the border into California are law-abiding, taxpaying members of our communities.

So, deciding the degree of criminality of border crossers will likely be the foundation of arguments for and against undocumented immigrants. There also is a humanitarian component that cannot be denied. Who among our readers does not know a neighbor or friend whose crime is not having the proper papers?

It will be an interesting debate, one we hope will be resolved with the idea that we are all in this together, and not on the basis of political dogma.