It’s been a bad few months for Rick Perry—actually, just a really bad entire campaign. His poll numbers are in the toilet; recently he has found himself in the news mainly for his campaign’s possible role in stoking allegations of sexual harassment against Herman Cain, and for a strange and fumbling speech he delivered last Friday in New Hampshire, which led many to wonder if he was drunk.

For the most part, we are relieved by this development. Perry would be a terrible president, far worse for the country than Mitt Romney. He has made clear that he would not just seek to undo ObamaCare, but also to roll back much of the progress of the last eight decades. His rhetoric about secession, his extremely conservative legal philosophy (documented by Jeffrey Rosen), his record as governor of Texas (explored in-depth by Alec MacGillis)—all of it suggested that a Rick Perry presidency would be very bad for both liberalism and the country.

And yet, there is one matter on which we actually feel a bit sorry for Perry. Nothing seems to have sped his collapse among conservatives more than his advocacy for a sensible and humane approach to illegal immigration. And so, before Perry’s candidacy fades into permanent irrelevancy (if that is indeed where it is headed), we wanted to thank him, sincerely, for having injected a note of compassion into the conservative discussion of immigration policy.

Soon after taking office back in 2001, Perry signed a state-level version of the DREAM Act into law, stating proudly that “our history is rich with examples of new citizens who have made great contributions. We must say to every Texas child learning in a Texas classroom, ‘we don’t care where you come from, but where you are going, and we are going to do everything we can to help you get there.’” Moreover, while he is hawkish on enforcement issues, Perry has shown himself to be sensitive to the practical limitations of such measures. On the conservative fantasy of building a giant wall across the entire southern U.S. border, he argued in 2006 that it “would not only be cost prohibitive—in the range of billions of dollars—it would create a false sense of security.” And when Arizona’s draconian immigration law divided the country in 2010, Perry said it wouldn’t be “the right direction for Texas.”

But his best moment on this issue came during a Republican debate. When assailed from all sides for his support of the DREAM Act, Perry said opponents of the measure “don’t have a heart.” Conservative pundits howled in outrage and disbelief, but Perry was exactly right. Punishing young children for the crimes of their parents is cruel and un-American. And, yes, completely heartless.

It’s easy to see how all this has hurt Perry with Republican voters. Romney, shameless as ever, leapt at the opportunity that Perry was providing him, creating possibly the most xenophobic and all-around disturbing attack ad aired by a major presidential candidate in recent memory. That ad was called, sarcastically, “Thank You Governor Perry.”

Of course, it’s important to note that Perry is hardly perfect on immigration. He has crassly referred to undocumented immigrants as “illegals,” and he later tried to walk back his comment about his critics not having a heart. Still, Perry at least provided a brief glance of sanity on immigration—and now is arguably something of a martyr on the issue, given that it appears to have sunk his candidacy. It doesn’t happen too often, but when a Republican stands up to his own base on an important issue, we think he or she should get sincere credit from liberals. So: Thank you, Governor Perry.