Landlocked Uganda has announced it will build a major pipeline to export its oil through Tanzania.
Uganda had planned to send the pipeline through Kenya, which wanted a joint facility for oil from its own fields that are under development.
The pipeline will now be routed further south, with concerns about possible attacks by Somalia's al-Shabab Islamists said to be a factor.
The group has attacked targets close to where the pipeline would have passed.
Uganda announced its decision in Kampala at a summit of the East African Community bloc, which groups Uganda, Kenya, Tanzania, Burundi, Rwanda and South Sudan.
The 1,400km (800 miles) pipeline will connect Uganda's western region near Hoima, where big oil reserves have been discovered, with Tanzania's port of Tanga.
The project is expected to cost about $4bn (£2.8bn) and create 15,000 jobs.
The discovered oil reserves in Uganda are estimated at some 6.5bn barrels, and the country expects to start production in 2018.
France's Total, China's CNOOC and the Anglo-Irish company Tullow hold most of the licences.
Kenya, which has also struck oil, had wanted the pipeline to pass through its territory.
Uganda had initially signed such a deal, but Total later questioned the plan over security concerns, the BBC's Catherine Byaruhanga in Kampala reports.
Ugandan Foreign Minister Sam Kutesa said on Saturday that the cost was also a factor in choosing the project.
"We considered Tanga oil pipeline route based on a number of aspects - among them it is the least cost," he told the AFP news agency.
Reports also suggest that Uganda backed the Tanzanian route because the country's port of Tanga is already fully operational, while Kenya's Lamu port is still being built.
When completed, it will be East Africa's first major oil pipeline.
Meanwhile, Kenya said it would build its own pipeline from Lokichar, in the north-east, to Lamu.