Patterico has a post on how the Mexican government is threatening to file a lawsuit if the U.S. uses National Guard troops to help control the southern border. While the AP story about the threatened lawsuit is not specific, my guess is that the lawsuit will allege that the National Guard will be performing a law enforcement function in violation of the Posse Comitatus Act. This Act is a general prohibition against use of the military for active law enforcement purposes.
I know a little about it, because I violated the law once, although entirely by accident. Back when I was in the Marines my squadron (VMO-1) was tasked with assisting Customs to help protect the border against drug smugglers. Part of this involved flying around the Bahamas, swooping down on sailboats to check them out (there were a lot of pretty girls on those sailboats) and sneaking up on civilian aircraft from behind so we could read their side numbers. That part was loads of fun. There was also a lot of night flying, some of it in dirty weather, which wasn't so much fun. (I remember once operating over water under a solid 1200 foot overcast. There wasn't a bit of ambient light, so the night vision stuff was useless, and there wasn't anything to see on the infrared. I soon pretty much forgot about the mission and spent the next three hours or so just trying to stay alive).
Anyway, one night we were vectored onto a drug smuggling aircraft that was coming in over the border. We used the infrared to follow him for a few hours, until he crashed while attempting to put down in a makeshift airfield.
My backseater saw a van pulling away from the crash sight in the infrared, so I figured "what the hell" and started to give chase. We terrorized the guy for about five minutes, until the van drove off into the woods and the occupants took off running. They didn't give off enough of a heat source for us to effectively track them on the infrared, so our fun was over for the night.
Anyway, years later while I was in law school I learned about the Posse Comitatus Act, and wondered why what we doing wasn't a violation. It turned out that Congress had passed a law right before the deployment, allowing the use of the military to track and monitor "air and sea traffic" in aid of the drug enforcement effort. That made it okay to follow boats and airplanes. But the van we chased wasn't on the land or sea, so I guess it was a violation. That was okay, nobody knew about it but me, and I wasn't talking. (Until now, I guess).
Anyway, the lawsuit doesn't sound like it will go anywhere. The Act doesn't apply to traditional military functions. And if protecting the nation's border isn't a traditional function, I don't know what is.