Oil firm Royal Dutch Shell was told a pipeline had reached the end of its life years before it spilled up to 500,000 barrels of oil, according to court documents seen by the BBC.
Two spills in 2008 affected about 35 sq miles (90 sq km) in southern Nigeria, according to a group suing Shell.
The area included sensitive mangroves.
Shell "dismisses the suggestion that it has knowingly continued to use a pipeline that is not safe to operate," it told the BBC.
The emails, letters and internal reports submitted to a court in London show that senior Shell employees were concerned before the spill that Shell's pipelines in the area had reached the end of their lives and needed replacing to avoid danger to lives, the environment and the economy.
The spills took place in Bodo, a town in the Ogoniland region, where people interviewed for an Amnesty International report into the effects of the incident reported headaches and eyesight problems.
Following the spills, the price of fish, a local staple food, rose as much as tenfold, according to Amnesty. People who worked in fishing had to find jobs in other industries which proved more difficult to find.
Oil spills in the Ogoniland region have also contaminated local drinking water sources, seeping into groundwater, according to a report from the United Nations Environment Programme (UNEP). Toxins found by UNEP in the wider Ogoniland area's drinking water include benzene, which is thought to cause cancer.
The two spills came from the same pipe on the Trans Niger Pipeline, operated by Shell, which takes oil from its fields to the export terminal at Bonny on the coast. It carries about 180,000 barrels of oil per day. The firm disputes the size of the spills and says much of the oil was spilt as a result of thefts and sabotage.
In September 2006 - two years before the spills - a letter from Basil Omiyi, managing director of Shell's Nigeria business, SPDC, to the governor of Rivers State said that the pipeline was of "immediate and utmost concern".
Shell had not inspected the pipeline for several years due to difficulties in accessing it, he said.
"There is a risk and likelihood of rupture on this pipeline at any time, which if it happens, could have serious consequences for the safety of life, the environment and the nation's economy."
Shell in Nigeria
• Shell stopped drilling oil in Ogoniland, which includes Bodo, in 1993 after growing unrest in the area.
• In 2009 Shell paid $15.5m in an out-of-court settlement in a case accusing it of complicity in human rights abuses in Nigeria. It was brought by relatives of nine anti-oil campaigners, including author Ken Saro-Wiwa, who were hanged in 1995 by Nigeria's then military rulers. Shell denied any wrongdoing and said the payment was part of a "process of reconciliation"
• In 2013, Shell produced 265,000 barrels of oil per day from Nigeria, which is 8.3% of the 3.2m barrels of oil per day it had for sale from its drilling business.
• The area is also one of the most cost-effective for Shell. The cost of producing a barrel of oil in Africa last year was $14.43. Only Asia and Oceania were cheaper. In Europe and the USA, the cost was $17.66 and $21.57
• Shell told its investors in its 2013 annual report of the "disputes" in Nigeria, where it "believes that the outcomes of these matters will ultimately be resolved in a manner favourable to Shell" albeit with the caveat "no assurance can be provided"
A study conducted in 2000 by Shell's Nigeria business and Shell Global Solutions International, the oil giant's consulting business, found "the remaining life of most of the SPDC oil trunklines is more or less non-existent or short, while some sections contain major risk and hazard."
An internal Shell email in December 2009, after the spills, said the firm was "corporately exposed as the pipelines in Ogoniland have not been maintained properly or integrity assessed for over 15 years."
"The decision by Shell to continue pumping oil through pipelines which they knew were not fit for purpose is quite shocking," said Martyn Day, a senior partner at Leigh Day, the lawyers representing the community filing the claim.
"The result was an environmental catastrophe for the Bodo Community and the biggest loss of mangrove habitat in the history of oil spills. The 40,000 residents of the Bodo Community primarily relied on fishing and their way of life and source of livelihoods has been destroyed for years to come," said Mr Day.
Shell, in documents submitted in its defence, admits its pipeline failed due to a faulty weld, but disputes the volume of spilled oil. It says much of the damage caused to the area comes from other spills, including damage from sabotage and attempts at theft.
Shell will pay "just and reasonable" compensation to those affected, it says.
Shell told the BBC: "SPDC ceased operations in Ogoniland in 1993 following a rise in violence, threats to staff and attacks on facilities. Levels of violence and criminality have remained high over the following 21 years, constraining SPDC's ability to access the area.
"The condition of the pipeline is regularly assessed.
"Also, SPDC has always made use of the opportunity presented during sabotage [and] crude theft point leak repairs to carry out on-the-spot coating and internal checks to confirm the integrity of the pipeline and coating."
The claimants, who are suing for a clean-up plus damages, say the illegal refining only started in earnest after the spills, which killed the fish they rely on for food and their livelihoods.
The area's humidity corrodes pipelines and its many rivers and lowlands means fixing a leak often necessitates wading through swamps, carrying floating booms and other equipment, which is slow work, according to one former Shell employee with whom the BBC spoke.
International industry rules call for operators to consider tools to detect corrosion in pipelines, leak detection equipment and so-called cathodic protection in environments where corrosion is a risk. This is where a structure, such as a pipeline, is protected from corrosion by an electric current.
There are no leak detection systems or flow rate meters on the pipeline, say the members of the community - systems which are industry standard in the West.
Shell was unable to use its other leak detection systems such as flow monitoring or acoustic sensors because they were sabotaged or stolen and it was "not reasonable to keep replacing such equipment," it said.
The claimants say the pipelines were not checked regularly for corrosion or failing welding by robots known in the industry as intelligent pipeline inspection gadgets, or PIGs. In the UK, pipelines would be inspected in this way every five years or so, according to industry experts.
Shell says it employed contractors to guard and monitor the pipeline and arranged for inspections from the air. The claimants say a lack of boats and too few people to adequately patrol made their job "inadequate".
The claimants say Shell didn't want to shut down the pipes that form the Trans Niger Pipeline because of the company's reliance on them, citing an internal Shell email which says "sustenance/stability via the TNP [pipeline] is key for our survival".
"From all we have seen in pursuing the Bodo claims, Shell has demonstrated a very worrying lack of care when it comes to the operation of their pipelines in the Niger Delta," said Mr Day, the community's lawyer.
Shell said: "We are in the process of preparing for a trial in May 2015 regarding the Bodo operational spills, at which time internal documents produced by SPDC relating to the Trans Niger Pipeline (TNP) will be set in their proper context for review by the court."