(Adds background, context, sources)
MEXICO CITY, Aug 19 (Reuters) - Mexico is close to an accord over a contractual dispute with the builders of several gas pipelines, President Andres Manuel Lopez Obrador said on Monday, heralding a solution to a case that has sapped investor confidence in his administration.
The dispute has also caused diplomatic frictions with Canada in particular, aggravating concerns that Lopez Obrador, a veteran leftist who took office in December, could call into question any contracts signed before he assumed the presidency.
Among the most prominent companies affected by the dispute are Canada's TC Energy Corp, Mexico's Grupo Carso, an infrastructure firm controlled by billionaire Carlos Slim, and IEnova, a Mexican unit of U.S. company Sempra Energy (NYSE:SRE).
State-run power utility the Federal Electricity Commission (CFE) has been pushing hard to renegotiate the contracts issued under the previous government, arguing the terms were unfair.
Lopez Obrador told a news conference that the companies were willing not to take the matter to court, and that he hoped to make an announcement by the weekend.
"I wanted to let you know that we may reach a deal this week, and a deal will be reached, because the companies accepted dialogue," he said, noting that an accord might be struck by Thursday and that it would bring large savings to taxpayers.
Lopez Obrador has characterized the six previous administrations as part of a corrupt, conservative "neo-liberal" era whose legacy has vowed to sweep away.
A person familiar with the negotiations said the deal taking shape would respect the original contracts. Lopez Obrador sees that if he failed to uphold the contracts, it could severely impair his ability to attract investment to his own projects, the person added.
A second person with knowledge of the matter said the government understood that it was likely to lose if the dispute went to international arbitration.
A third person familiar with discussions surrounding Grupo Carso's pipeline project between Samalayuca and Sasabe in northern Mexico said the company had reached a deal with the government and that its contract had not been modified.
Carso did not immediately reply to a request for comment.
Lopez Obrador sent shivers through international markets when he abruptly canceled a partly built $13 billion Mexico City airport a few weeks before taking office. However, he took pains to compensate companies affected by the cancellation.