Cruz speaks at Tuesday's debate. (Robyn Beck/AFP/Getty Images)

This story has been updated.

Sen. Ted Cruz was put on the defensive Wednesday about the role he played in a failed Senate attempt at immigration reform, asserting that he did not support granting undocumented immigrants a pathway to legalization.

Appearing on Fox's  "Special Report with Bret Baier," Cruz was pressed by the anchor for his reasons for putting forward an amendment that allowed undocumented immigrants to get legal status -- a position Cruz is now against. Cruz's plan would have stripped out a provision granting a pathway to citizenship for undocumented immigrants -- which Cruz calls "amnesty" -- but would have allowed them to have some type of legal status, such as a work permit.

Baier played a clip of Cruz saying he wanted immigration reform to pass and that the amendment would have let "those illegally to come in out of the shadows."

Cruz is against undocumented immigrants receiving legal status, a position he long dodged and finally answered Tuesday night.

Read: Ted Cruz finally says what he’d do about undocumented immigrants

"Actually, Bret, it wouldn't have" provided legal status, Cruz said, asserting it was a battle over the immigration bill -- which was co-sponsored by Sen. Marco Rubio (R-Fla.), a rival for the GOP presidential nomination with whom Cruz has repeatedly clashed.

Read: Cruz takes the gloves off, attacking Rubio on immigration 

"I was leading the fight against amnesty," Cruz said.

Baier asserted Cruz never said that, citing quotes from Yahoo News and other sources where Cruz said at the time that the amendment was a compromise that could increase the chances of the bill becoming law.

"Of course I wanted the bill to pass, my amendment to pass," Cruz, who appeared thrown off by the exchange, said. "What my amendment did was take citizenship off the table. It doesn’t mean that I supported the other aspects of the bill, which was terrible."

Cruz's campaign has said that the amendment was meant to be a poison pill to show that those pushing for immigration reform at the time only cared about granting undocumented immigrants a pathway to citizenship. Baier pointed to past interviews where Cruz said he didn't want to kill the chance at immigration reform and contrasted them with his statements now, asking, "which one should people  believe?"

Read: It’s on: Rubio and Cruz clash over immigration and the GOP’s future

Cruz said he introduced five amendments that "illustrated the hypocrisy of the Democrats." The immigration bill never did pass Congress.

The Texas Republican significantly hardened his stance on immigration Tuesday, stating he does not support granting undocumented immigrants legal status. It is the farthest Cruz has gone on the issue, and the answer came during the Republican debate in an exchange with Rubio.

At a press conference in Los Angeles, Cruz was asked about immigration, stating he has been constant on the issue. He also took the opportunity to knock Rubio.

"My stance on immigration has been consistent I categorically oppose amnesty. My first priority is securing the border. As president, I will secure the border," he said.

Rubio, he said, chose to stand with Democrats "and with the big money and power in Washington and push a massive amnesty plan that would have driven up unemployment for working men and women, that would have driven down wages and would have undermined the rule of law and would have failed to secure the borders and keep this country safe," he said.

A number of Cruz's positions on immigration have shifted in the past few years. Cruz, who bills himself as a "champion of legal immigration," once supported doubling the caps on green cards and increasing the number of the visas for high-tech workers – known as H1-B visas – five-fold. Cruz now wants new limits on legal immigration and to temporarily halt the H1-B program, which has been rife with reports of abuse. He introduced a bill to reform it this month.

Ted Cruz unveils immigration plan — on Marco Rubio’s home turf

Cruz has accused Rubio of being too soft on immigration because he co-sponsored the bill; Rubio claims that he and Cruz have very similar views on immigration, noting that Cruz pushed the amendment.

This story was updated to correct the spelling of Baier's first name; it is Bret.