The pipeline had been projected to carry oil nearly 1,200 miles (1,900km) from the Canadian province of Alberta down to Nebraska, to join an existing pipeline.
Environmentalists and Native American groups have fought the project for more than a decade.
Development of the pipeline was blocked by the Obama administration in 2015, but President Trump overturned that order and allowed it go ahead.
What is Keystone XL?
A planned 1,179-mile (1,897km) pipeline running from the oil sands of Alberta, Canada, to Steele City, Nebraska, where it would join an existing pipe. It could carry 830,000 barrels of oil each day.
It would mirror an existing pipe, also called Keystone, but would take a more direct route, boosting the flow of oil from Canada.
A section running south from Cushing in Oklahoma to the Gulf of Mexico opened in January 2014. At the coast there are additional refineries and ports from which the oil can be exported.
The pipeline was set to be privately financed, with the cost of construction shared between TransCanada, an energy company based in Calgary, Alberta, and other oil shippers. US-produced oil would also be transported by Keystone XL, albeit in smaller quantities than Canadian.
Why did the US and Canada want XL?
Canada already sends 550,000 barrels of oil per day to the US via the existing Keystone pipeline. The oil fields in Alberta are landlocked and as they are further developed require means of access to international markets. Many of North America's oil refineries are based in the Gulf Coast, and industry groups on both sides of the border want to benefit.
An increased supply of oil from Canada would mean a decreased dependency on Middle Eastern supplies.
According to market principles, increased availability of oil means lower prices for consumers.
Mr Trump said the project would create 28,000 construction jobs.
Canadian Prime Minister Justin Trudeau had also supported the pipeline and said "we are disappointed but acknowledge the president's decision" to cancel the permit to build it.