Hillary Clinton on Tuesday broke her years-long silence over her stance on the Keystone XL pipeline, announcing in Iowa that she opposes the controversial project.

The former secretary of state previously had dodged questions about her position on the pipeline, citing her role in reviewing the project at the State Department and saying the ongoing review needs to run its course.

But during a campaign stop in Des Moines, the Democratic presidential candidate said she thought the matter "would be decided by now."

"But it hasn't been decided and I feel now I've got a responsibility," she said. Clinton went on to say the pipeline is a "distraction" from important work to be done on climate change, and "one that interferes with our ability to move forward with all the other issues -- therefore I oppose it.

"And I oppose it because I don't think it's in the best interest of what we need to do to combat climate change. I will be rolling out in a few days my plan for a North American approach to fighting climate change and clean energy. Because for me, we need to be transitioning from fossil fuels—I know it will take time—to clean renewable energy."

She announced her position at a time when her leading primary competitor, Vermont Sen. Bernie Sanders, is running in part on opposition to the Canada-to-Texas pipeline.

The latest headlines on the 2016 elections from the biggest name in politics. See Latest Coverage →

The project, though, put Clinton in a difficult political position, as it pits environmental activists who oppose it against labor unions who support it.

Sanders, for his part, praised Clinton for "finally" announcing her opposition to the project.

"As a senator who has vigorously opposed the Keystone pipeline from the beginning, I am glad that Secretary Clinton finally has made a decision and I welcome her opposition to the pipeline. Clearly it would be absurd to encourage the extraction and transportation of some of the dirtiest fossil fuel on the planet," he said in a statement.

Sen. Lindsey Graham, R-SC, and another presidential candidate, was quick to attack Clinton for her remarks.

“In opposing the Keystone oil pipeline, Hillary Clinton once again shows that she intends to continue the failed policies and poor decisions of the Obama Administration," Graham said in a statement.

"Building this pipeline is essential to our national security by reducing our dependence on oil from countries that hate us. Keystone represents sound environmental policy that will move the American economy in the right direction and strengthen our national security."

Republican presidential contender Carly Fiorina told a South Carolina town hall meeting, "let's see, it took her two years to figure out what her position is on the Keystone pipeline.  And then after two years where actually the facts haven't changed, predictably perhaps, she sided with the left wing of her party."

Clinton's stance risks a backlash from labor unions and others. The timing of her statement was curious -- she made her remarks just after Pope Francis arrived in Washington at the start of a closely watched visit to the United States.

The Obama administration continues to review the project, whose federal consideration has dragged on for years. While Clinton's remarks could complicate that process, they also appear to run against comments the former secretary of state made while holding that office.

In 2010, then-Secretary Clinton indicated potential support for the project as she told a San Francisco audience, "We're either going to be dependent on dirty oil from the [Persian] Gulf or dirty oil from Canada."

The Associated Press contributed to this report.