The decision caps a years-long fight that became a proxy battle over global warming.

President Donald Trump declared it a "great day for American jobs" on Friday as he formally green-lighted the Keystone XL pipeline, clearing the way for the $8 billion project to finally be completed.

In a reversal of the Obama administration's earlier decision, the Trump administration issued a presidential permit enabling Calgary-based TransCanada to build the pipeline. Appearing alongside TransCanada's CEO in the Oval Office, Trump called it part of a "new era of American energy policy" that he said would lower costs, reduce reliance on foreign oil and create thousands of U.S. jobs.

"It's going to be an incredible pipeline," Trump said. "Greatest technology known to man or woman and, frankly, we're very proud of it."

He said TransCanada could now build Keystone "with efficiency and with speed" and said the federal government was working out final details "as we speak."

The decision caps a years-long fight between environmental groups and energy industry advocates over the pipeline's fate that became a proxy battle over global warming. It marks one of the biggest steps taken to date by the Trump administration to prioritize economic development over environmental concerns.

The State Department, responsible for reviewing the project because it crosses an international border, determined that building it serves U.S. national interests. That conclusion followed a review of environmental, economic and diplomatic factors, the department said.

It wasn't immediately clear what, if anything, had changed since the State Department reached the opposite conclusion two years ago, other than the election of a new administration. President Donald Trump planned to address Keystone during an announcement on Friday morning, White House spokesman Sean Spicer said on Twitter.

TransCanada, which first applied for a presidential permit in 2008, called the decision a "significant milestone."

"We greatly appreciate President Trump's administration for reviewing and approving this important initiative," said TransCanada CEO Russ Girling. "We look forward to working with them as we continue to invest in and strengthen North America's energy infrastructure."

But Greenpeace, one of the pipeline's most vocal opponents, said it sent a signal to the world that the U.S. is "moving backwards" on climate and energy, and pledged to keep fighting it nonetheless.

"Keystone was stopped once before, and it will be stopped again," said Annie Leonard, the group's U.S. director.

The 1,700-mile (2,735 kilometers) pipeline, as envisioned, would carry oil from tar sands in Alberta, Canada, to refineries along the Texas Gulf Coast, passing through Montana, South Dakota, Nebraska, Kansas and Oklahoma. The pipeline would move roughly 800,000 barrels of oil per day, more than one-fifth of the oil Canada exports to the U.S.

Portions of Keystone have already been built. Completing it required a permit to cross from Canada into the U.S.

Yet even with a presidential permit, the pipeline still faces obstacles - most notably the route, which is still being heavily litigated in the states. Native American tribes and landowners have joined environmental groups in opposing the pipeline.

TransCanada said Friday it would continue engaging with "neighbors throughout Nebraska, Montana and South Dakota to obtain the necessary permits and approvals to advance this project to construction."

In an unusual twist, the presidential permit was signed by Tom Shannon, a career diplomat serving in a senior State Department role, rather than by Secretary of State Rex Tillerson. The former CEO of oil company Exxon Mobil recused himself after protests from environmental groups who said it would be a conflict of interest for Tillerson to decide the pipeline's fate.

Canadian Natural Resource Minister Jim Carr said the Canadian government is pleased with the decision. Ninety-seven percent of Canada's oil exports go to the U.S.

"Nothing is more essential to the American economy than access to a secure and reliable source of energy. Canada is that source," Carr said.

Oil industry advocates say the pipeline will improve U.S. energy security and create jobs, although how many is widely disputed. Calgary-based TransCanada has promised as many as 13,000 construction jobs — 6,500 a year over two years — although the State Department previously estimated a far smaller number. The pipeline's opponents contend the jobs will be minimal and short-lived, and say the pipeline won't help the U.S. with energy needs because the oil is destined for export.

A Trump presidential directive also required new or expanded pipelines to be built with American steel "to the maximum extent possible." However, TransCanada has said Keystone won't be built with U.S. steel. The company has already acquired the steel, much of it from Canada and Mexico, and the White House has acknowledged it's too difficult to impose conditions on a pipeline already under construction.

Environmental groups also say the pipeline will encourage the use of carbon-heavy tar sands oil which contributes more to global warming than cleaner sources of energy. President Barack Obama reached the same conclusion in 2015 after a negative recommendation from then-Secretary of State John Kerry.

TransCanada first applied for a permit in 2008. Years of politicking, legal wrangling and disputes over the pipeline's route preceded Obama's decision to nix the project.

The Obama administration argued the pipeline would undercut U.S. efforts to clinch a global climate change deal that was reached weeks later in Paris.

The Trump administration has dropped fighting climate change as a priority and left open the possibility of pulling out of the Paris deal.