The $3.5bn (£2.7m) project will connect Uganda’s oil fields to Tanzania’s port of Tanga.
The signing ceremony was attended by the presidents of both countries.
Oil reserves were found in Uganda in 2006 but production has been delayed partly by a lack of infrastructure including an export pipeline.
A start date for construction has not yet been announced for what is set to become East Africa’s first major oil pipeline.
But there are warnings the project could come at a huge cost to some Ugandan communities.
Uganda has proven oil reserves exceeding 6.5 billion barrels, of which about 2.2 billion barrels are recoverable. The country plans to build a refinery in the Western Region to meet local and regional demand, with the rest exported via pipeline to the Indian Ocean coast
Concerns regarding security and cost, however, motivated parallel negotiations with Tanzania regarding a shorter and safer route to Port Tanga, with the support of the French petroleum conglomerate Total SA.
At the 13th Northern Corridor Heads of State Summit in Kampala in April 2016, Uganda officially chose the Tanzania route for its crude oil, in preference to the Mombasa or Lamu routes in Kenya. The presidents of both Kenya and Rwanda were present, along with representatives from Ethiopia, South Sudan, and Tanzania.
The construction budget for the 1,445 kilometres (898 mi) pipeline is US$3.5 billion. The pipeline is planned to have a capacity of 216,000 barrels of crude oil per day. It will be 24 inches (61 cm) in diameter, and Uganda will pay Tanzania US$12.20 for every barrel flowing through the pipeline.