The announcement on Friday said the State Department “considered a range of factors, including, but not limited to, foreign policy; energy security; environmental, cultural and economic impacts; and compliance with applicable law and policy.”

The new secretary of state, Rex W. Tillerson, formerly the chief executive of Exxon Mobil, had recused himself from the decision. The announcement said the permit was signed by the under secretary of state for political affairs, Thomas A. Shannon Jr.

The pipeline still faces hurdles before it can be built. It needs the approval of the Nebraska Public Service Commission and local landowners who are concerned about their water and land rights. Protests are likely since the project has become an important symbol for the environmental movement, with the Canadian oil sands among the most carbon-intensive oil supplies. Mining the oil sands requires vast amounts of energy for extraction and processing.

In addition, interest among many oil companies in the oil sands is waning amid sluggish oil prices. Extraction from the oil sands, situated in the sub-Arctic boreal forest, is expensive. Statoil and Total, two European energy giants, have abandoned their production projects. In recent weeks, Royal Dutch Shell agreed to sell most of its oil sands assets for $8.5 billion. And Exxon Mobil wrote down 3.5 billion barrels of reserves, conceding the oil sands were not economically attractive enough to develop for the next few years at least.

Nevertheless, Canadian production continues to grow as projects that were conceived when prices were higher begin to operate. And the Keystone effort is central to the future of TransCanada, a major force in the Canadian oil patch.