Crisis talks were held weekly between the chief executives of the agencies and IBM, the documents show, and high-powered legal advice was obtained from Crown Law and the Chapman Tripp firm.
Ministers of relevant departments, the Department of the Prime Minister and Cabinet and the State Services Commission were also briefed on the problems with JBMS.
A court case was avoided after 10 months of negotiations.
A briefing paper for the Cabinet said the "parties have now agreed to a mutually acceptable arrangement that will ensure ... the JBMS is delivered in the most cost-effective way that manages the risks associated with a sizeable information technology project".
The specific problems with JBMS and the agreement with IBM remain secret because of heavy redactions in the released documents.
But funding for the first stage of the project was lifted from $75.9 million to $89.7 million last year.
The briefings released to the Herald show a request for another $14.4 million was approved this year because of "funding pressure".
The delays have been blamed on unexpected complications in integrating new and existing systems, which has taken longer than expected to develop and test.
A Customs spokeswoman said the renegotiated agreement with IBM was "commercial in confidence" and remained secret.
Part of the agreement is that IBM is locked in to provide support and "enhancement" of the programme for seven years.
Labour MP David Shearer said the JBMS project was on its way to becoming another Novopay, but the problems had been kept quiet before the election.
"This is nearly $30 million over budget and at least three years late. This is another Government IT project going off the rails."
A spokesman for Customs Minister Nicky Wagner did not respond to questions yesterday.
A Herald investigation last December revealed the delays and rising costs of the ambitious project.
It was decided in June 2012 to split the first stage of JBMS into multiple steps because of the "risks of delivering such a complex system with many interdependencies''.
The first step, known as the Trade Single Window, is described as a "one-stop shop'' for importers and exporters to directly enter information through an electronic screen.
It was delayed three times and went "live" in August last year, but is not running at full capacity.
However, the core of the first stage is sophisticated risk and intelligence tools for "smarter" targeting of people, goods and craft crossing the border which is still not operating.
This is now expected to be completed by December next year.
Plans for the second stage of JBMS - intended to retire Customs and MPI's existing systems at the end of this year - for another $65 million have been scrapped in favour of "a set of phased, discrete initiatives to modernise border capabilities".
Concerns first aired back in April 2012
Concerns about the "largest information technology programme ever undertaken by Customs" were first flagged in April 2012 by a review on behalf of the State Services Commission.
The Performance Improvement Report said it was "concerning to hear the scope of the risk and intelligence tools" had not been finalised.
"Adding to this, we were advised that the main contractor was having difficulty in bedding down these new tools and although we were not able to explore this in any detail, it is an issue which Customs needs to address," said the report.
"There are many examples of information technology programmes having struggled or failed due to poor scope control and scope control for JBMS should be addressed as quickly as possible. The scope should be locked down and any further changes should only be agreed at the most senior level and only for absolutely essential changes."
A follow-up review published this year said the JBMS had "proved to be more difficult than envisaged". With the decision to stage implementation over a series of releases, the delivery date had been extended, it said.
"There is also more work needed to fully implement the risk and intelligence tools ... which are also proving difficult to develop."
Until these tools were in place, it said, other intelligence tools to protect the border could not run at full capacity.
Budget:
• $75.9m in 2010
• $89.7m in 2013
• $104.1m in 2014