(CNN) With Sen. Kirsten Gillibrand entering the 2020 presidential race on Tuesday, her dramatic shift on the issue of immigration over the past decade will likely be one of the central questions about her candidacy as she seeks to take on President Donald Trump.

Gillibrand, as a congresswoman for a little more than two years from a mostly white and more conservative district in upstate New York, opposed "amnesty for illegal immigrants" and voted to increase funding for US Immigrations and Customs Enforcement (ICE) to work with local law enforcement on deportations. As the junior senator from New York, Gillibrand now espouses much more liberal positions on the issue, and last year called for the abolishment and reimagining of ICE.

A review by CNN's KFile of Gillibrand's old campaign websites and materials, speeches, interviews and legislative history show how central Gillibrand's conservative positions on immigration were to her message during her brief career as a member of the House.

Running for the House in 2006, Gillibrand attacked her opponent from the right on immigration and called securing the border "a national security priority." In a 2007 interview, Gillibrand said "you have to close the borders" as a first step to "right size" immigration. In a 2008 mailer sent from her congressional office, Gillibrand touted her efforts to expedite "the removal of illegal aliens by expanding detention capacity and increasing the number of Federal District Court judges."

Those positions could complicate her ability to effectively challenge Trump, who has taken similar positions and has made his opposition to illegal immigration central to his political message.

Gillibrand has called aspects of her record in the House from 2007 through early 2009 something she is "embarrassed" and "ashamed" of, and she's said her change on the issue has come from understanding the perspective of undocumented immigrants living in fear of the deportation of a family member.

"I think it is important to know when you are wrong and to do what is right, and I will do what is right and I will fight for what is right and I don't back down from those fights," Gillibrand told reporters Wednesday when asked about her shifts on issues like immigration.

But the timing of the shift -- shortly after she was appointed to the Senate in 2009 to succeed Hillary Clinton -- has opened her up to criticism that she flip-flopped on a key issue for political reasons. Shortly after Gillibrand announced her exploratory bid for the presidency on Tuesday, the Republican National Committee, citing her position on ICE and others, issued a statement attacking her as an opportunist.

Meredith Kelly, the communications director for Gillibrand's exploratory committee, told CNN in a statement, "It takes courage to admit when you are wrong, and Kirsten has made clear that she regrets positions she took years ago in the House related to immigration.

"Since coming to the Senate and hearing from families all across the state, Kirsten has been a steadfast and compassionate advocate for immigrants, and will continue to drive progress on comprehensive immigration reform, immigrant rights and strengthening the legal immigration system that makes us Americans."

Immigration central to 2006 run

Gillibrand positioned herself as an immigration hawk during her 2006 campaign for Congress and said securing the southern border was a national security priority.

In a statement touting her support for the measure, Gillibrand called a secure border a national security priority and said congressional Republicans and her opponent Republican Rep. John Sweeney had failed to take the lead on improving border security.

"I support protecting our borders, but our solution must include more measures to ensure employer enforcement with regards to illegal immigration, building a wall or a fence alone is simply not enough," Gillibrand said . "In conjunction with solutions taken on the ground at our borders, we must enforce the employment laws that are currently being ignored by companies who profit from hiring illegal immigrants. The urgency of dealing with our borders should not be held hostage by election year legislation and this summer's field hearings; securing our borders must be a national security priority."

"Threats at our borders need serious solutions from Washington and we have yet to see John Sweeney and Congressional leadership take the lead on improving our border security," she added. "Under the Bush Administration, the number of illegal immigrants apprehended at our border is down 31%. This is not solely an immigration question; improving our border security is imperative in keeping America safe."

Gillibrand won her election, becoming one of a number of Democrats swept into Congress in the 2006 midterm Democratic wave that gave them control of the House for the first time in 12 years.

Votes in the House

In Congress, Gillibrand joined the Blue Dog Coalition of moderate Democrats and established herself as a hawk on immigration in the House. Articulating her views in an interview with a local Albany blogger in May 2007 , Gillibrand said the borders needed to be closed.

"I think we should be dealing with immigration to 'right size' immigration. First step, you have to close the borders. Second step, you have to increase enforcement dramatically. There has been no enforcement under this past administration," Gillibrand said, adding the lack of enforcement could mean undocumented immigrants worked in unsafe environments. Gillibrand said workers needed for certain industries would need to come in legally.

Gillibrand's record on immigration earned her a B rating from Numbers USA, a hardline group that advocates for stricter immigration laws and cuts to legal and illegal immigration.

"Illegal immigrants should not have access to driver's licenses," she said in a statement when Spitzer backed down from the plan . "With regard to illegal immigration, the Bush administration has failed to enforce our laws and secure our borders. Congress needs to act now."

Gillibrand was also a co-sponsor of the SAVE Act , a bill from Democratic Rep. Heath Shuler, opposed by pro-immigration groups but largely supported by Republicans. The bill was an enforcement-only approach to immigration that would have increased border security by adding 8,000 new border patrol agents, made it easier to deport undocumented immigrants, required companies verify the legal status of their workers and added an additional 1,150 ICE agents.

Gillibrand was one of three co-sponsors to a bill to require that all employers verify they had legal workers through the Social Security Administration, but the bill didn't move beyond committee.

Gillibrand's votes frequently aligned her with Republicans and other moderate Democrats and she was often voting in the majority.

Gillibrand also took the issue on herself, passing her own amendment to a bill on federal contracting that would punish employers of undocumented immigrants by barring them from receiving contracts from the federal government. The amendment was passed by a voice vote.

"My amendment to this bill is very simple: businesses that continue to break the law by hiring illegal aliens should not be eligible for federal contracts," Gillibrand said in a speech on the House floor . "We must reward businesses that play by the rules and punish those who do not. It is important that we fix our broken immigration system, and an important component of that is to cut off the availability of jobs for undocumented workers -- which can only be done when employers refuse to hire them. There are an estimated 12 million illegal aliens in this country, and if jobs are not available to them, then there will not be an incentive for them to come or remain here in America illegally."

2008 campaign for re-election

Gillibrand campaigned heavily on her record on immigration in the House during her first re-election campaign. An issues page on her House website , put up a year into her term, boasted of her voting record in the House, including her support for the SAVE Act and the passage of her amendment, as well as the bill to require employers verify the legal status of their workers.

"I am firmly against providing amnesty to illegal immigrants," she said on the page.

A page put up on her website for her 2008 re-election campaign similarly boasted about her record, adding that the congresswoman believed that English should be the official language of the United States and no non-emergency taxpayer money should benefit undocumented immigrants.

In May 2008, Gillibrand spent $35,000 of her congressional office's money to send out an anti-undocumented immigration mailer to her constituents that drew fire from her Republican opponent, Sandy Treadwell , who said Gillibrand should "pay for her self-promotion efforts from her campaign funds, instead of billing taxpayers."

The mailer, a copy of which CNN's KFile obtained from the Capitol's Legislative Resource Center , touted how Gillibrand's sponsorship of the SAVE Act would increase the speed in which undocumented immigrants were deported.

One page of the mailer featured a photo of a hole on the southern border fence with a later page showing it covered by a sign boasting Gillibrand "opposes amnesty for illegal immigrants."

A shift on immigration in the Senate

In January 2009, Gillibrand was appointed to replace Clinton, who had been confirmed to be President Barack Obama's new secretary of state. Her appointment was met with backlash from New York-based immigration activists

Gillibrand sought to quell the concerns by meeting with immigration groups. After meeting with activists , Gillibrand announced that she supported several more liberal positions on the issue, like a moratorium on raids until comprehensive immigration reform was achieved.

The meetings seemed to work.

"We saw a very positive shift in attitude in the way that she looks at immigrant constituencies," said Chung-Wha Hong , former executive director of the New York Immigration Coalition , who met with Gillibrand, to the New York Daily News at the time.

"Only time will tell where she's going to end up on this," Rivera said . "But from what I've seen from all her statements and all her stance, she's with the immigrant community 110%. I cannot now say that she's anti-immigrant. She's become a strong supporter of immigrant issues in the state and the nation, in the course of a week. I really didn't think she could move that fast on the issue, that she'd be bound by complexity and the traditions of life."

Rep. Nydia Velazquez, a New York Democrat and former chair of the Congressional Hispanic Caucus, talked about Gillibrand's shift on the issue in a statement to CNN.

"While I am not endorsing a candidate at this time, I consider Kirsten a friend and, almost a decade ago, I witnessed firsthand the meaningful evolution of her thinking on immigration," Velazquez said. "Very shortly after becoming Senator, she reached out to me directly and we had multiple conversations where she listened, learned and demonstrated genuine compassion for what families across New York have experienced from our broken immigration system. Since then, she's been a fighter and a tireless ally on these issues who I deeply value."

Gillibrand moved in the Senate to support policies advocated by the activists, including in March 2009, when she signed on as a co-sponsor of the DREAM Act

Gillibrand was asked about her past positions in a 2018 interview with 60 Minutes, where she said, "I just didn't take the time to understand why these issues mattered because it wasn't right in front of me. And that was my fault. It was something that I'm embarrassed about and I'm ashamed of."

She added, "I just think as I've gotten older I've learned more about life and sometimes you're wrong. And you've gotta fix it. And if you're wrong, just admit it and move on."

Clarification: This story has been updated to more precisely describe Numbers USA.