Julián Castro took former Vice President Joe Biden to task at last week's Democratic presidential primary debate for trying to downplay his role in the Obama administration’s immigration policies -- but Castro wasn't always a big critic of those policies either.

In 2012, when Castro was mayor of San Antonio, he said Obama "certainly gets it" when it comes to immigration and treating people "humanely."

DEMOCRATIC PRESIDENTIAL CANDIDATES DEBATE WHO WILL BEST KEEP OBAMA'S LEGACY

"He’s easily been the best friend that Latinos have had in the White House," Castro told the Texas Tribune.

Later that year, in an interview with Charlie Rose, Castro was asked to describe the "best and most realistic immigration policy," and his answer now sounds almost Trumpian.

"First it`s going to continue to make sure that the borders are secure, it`s going to enhance that," he said. "Secondly, work with employers to establish an even better system so that they can know when they hire someone that they`re hiring someone who`s here legally. And then third it`s going to set up some way to deal with the 11 to 12 million folks who are here, undocumented, illegal, whatever you want to call them."

Video from a 2013 House Judiciary Committee hearing, flagged this week by The Washington Free Beacon, also shows Castro endorsing a relatively tough approach to the border. He discussed how the Obama administration achieved "unprecedented success" in deporting "dangerous individuals" due to having "more boots on the ground along the border than at any other time in our history."

When asked if “interior enforcement” should be used to discourage future illegal immigrants by keeping them from getting jobs, Castro said, “Going forward, of course, enforcement is part of the conversation.”

Castro, who later became President Barack Obama's secretary of Housing and Urban Development, also touted “active enforcement on our borders” and said that under Obama “there has been tremendous progress with regard to enforcement.” Obama’s critics, however, referred to him as the “deporter in chief.”

Cut to 2019, and Castro criticized Biden for trying to “take credit for Obama’s work but not have to answer to any questions,” after Biden was challenged on Obama-era immigration enforcement policies during last week's debate. He is also distancing himself from his past support for Obama's policies.

"He was applauding the administration’s effort to prioritize immigration enforcement, not their efforts to deport mass numbers of immigrants," Castro campaign spokesperson Sawyer Hackett told the Texas Tribune.

Castro’s current position is far removed from when he described Obama’s immigration enforcement practices as “progress.” He now calls for decriminalizing illegal border crossings and wants undocumented immigrants to receive free health care, at a time when President Trump accuses Democrats of supporting “open borders.”

During that same 2013 hearing, Castro said that open borders would be an “extreme” policy.

“Nobody agrees with open borders,” he said. “Everyone agrees we need to secure our border.”

2020 CANDIDATES PUSH BACK ON CASTRO FOR QUESTIONING BIDEN'S MEMORY

Former Obama officials have hardly been on the same page regarding the current immigration debate. Former Obama Homeland Security Secretary Jeh Johnson told The Washington Post in July that decriminalizing unauthorized border crossings would be "tantamount to declaring publicly that we have open borders," and that it "is unworkable, unwise and does not have the support of a majority of American people or the Congress, and if we had such a policy, instead of 100,000 apprehensions a month, it will be multiples of that."

When asked during a June 2019 ABC News interview if his current policies were essentially the same as open borders, Castro said, “There’s no way that we can call that open borders because we have 654 miles of fencing, we have thousands of personnel at the border, we have planes, we have helicopters, boats, security cameras, guns.”

According to his website, however, Castro’s immigration plan would "[e]ffectively end the use of detention in conducting immigration enforcement, except in serious cases." It also calls for ending border wall construction and cutting U.S. Immigration and Customs Enforcement (ICE) in half by getting rid of Enforcement and Removal Operations by spreading its responsibilities to other agencies like the Justice Department.

He also noted that there is a civil court system where people can still be deported and that not everyone who applies for asylum gets it.

When asked by Fox News how Castro’s current policies can be reconciled with his past statements, and how prohibitions on illegal immigration would be enforced according to his plan, Castro’s campaign did not respond. In a recent statement to the Texas Tribune, Hackett said, "Secretary Castro, unlike some candidates running in 2020, has learned the lessons of the past on immigration reform, including that no amount of deportations will bring Republicans to the table to negotiate."

One position that Castro has clearly maintained over the years is his support for creating a pathway to citizenship for undocumented immigrants already in the U.S.

“I do believe that a pathway to citizenship should be the option,” he said in 2013. “I do not see that as an extreme option.”