BEIRUT — Just days before the massive explosion this month at Beirut's port, there was an unusual flurry of activity around Warehouse Number 12, in which a stockpile of 2,750 tons of highly explosive ammonium nitrate had been sitting, unclaimed and unattended, for over six years.

Acting on an order from Lebanon's top judge, three workers were dispatched to fix a broken door, seal off a gaping hole in the warehouse's southern wall and ensure that all the other doors were tightly locked, according to documents obtained by The Washington Post and interviews with officials involved in the blast investigation. The work continued until the afternoon of the blast.

It was apparently the first time since the ship transporting the cargo of ammonium nitrate had docked in Beirut in 2013 that any concrete steps had been taken to secure the dangerous material. But the possibility of theft — not safeguarding against an explosion — seemed to be authorities' foremost concern, according to the documents and interviews.

Instead of protecting the explosives, sealing off the warehouse may have increased the risk of disaster, leaving the ammonium nitrate trapped in a warehouse secured so tightly that when firefighters were summoned around 5:50 p.m. on the afternoon of Aug. 4, they could not gain entry to fight the blaze.

Port employees who might have had keys had gone home for the day, said Col. Nabil Khankarli, Beirut's fire chief. A video shows three firefighters desperately trying to ram open one of the locked doors, as dense black smoke billowed from the warehouse's narrow windows.

Inside was a toxic mix of chemicals and explosives — including kerosene, gas oil, 25 tons of fireworks, five miles of blast fuses of the kind used in mining and quarrying, and solvents used for stripping paint — that had been stored alongside the ammonium nitrate, according to Ghassan Oueidat, Lebanon's chief prosecutor. Oueidat, in his role as judge, ordered the warehouse sealed in response to a request by the country's State Security agency. He cited the official inventory that investigators have since retrieved from port servers.

At 6:08 p.m., the entire warehouse blew up, with a force so massive that it wrecked several densely populated neighborhoods, killed at least 180 people, wounded over 6,000 and enveloped the city in a pall of grief and misery. Among the dead were 10 firefighters.

Washington Post correspondent Sarah Dadouch visited the port in Beirut one week after a massive explosion killed more than 170 people. (The Washington Post)

The blast was preceded by a seven-year saga of official neglect, incompetence and insouciance that raises questions as to whether anyone in Lebanon fully appreciated the danger posed by the ammonium nitrate — or cared enough to find out, let alone take steps to address the risk.

Oueidat, who has faced scrutiny for not taking more decisive action before the disaster, said he hadn't been made aware of the contents of the warehouse or the full risks posed by ammonium nitrate when the State Security agency sought his permission to secure the facility.

The State Security agency "called me and said they were afraid of stealing," he said in an interview. "They told me there were nitrates. They didn't tell me there were other materials. I told them to secure the place and seal it so nobody can steal it."

A report sent to the offices of the president and the prime minister from the State Security agency, dated July 20, confirms that theft was the foremost concern.

"This substance is dangerous and is used in the manufacture of explosives. If it were stolen, the thief could use it to manufacture explosives," said the report, which outlined the steps being taken to secure the warehouse.

Elsewhere, the report referred to the potential for a "catastrophe" if the ammonium nitrate were to explode. But the emphasis was on the risk of thefts. The hole in the warehouse wall and the broken door "would allow anyone to access it," the report added.

Exactly what caused the initial fire or explosion that triggered the massive blast is still unknown, investigators say. One of the possibilities being investigated is that sparks from the welding undertaken by the three workers — Syrians who left the port before the explosion and are now in custody — may have ignited a fire that eventually set off the ammonium nitrate. A person close to the investigation, who spoke on the condition of anonymity to discuss the ongoing process, said the Syrians worked at the site from July 31 until the day of the blast but had already left for home when the explosion occurred.

Security officials say they are also investigating whether a fire was deliberately set to mask evidence of the theft of ammonium nitrate that the State Security agency appeared to be probing.

What is clear, said Jeffrey Lewis, an arms-control expert and professor at the Middlebury Institute of International Studies, is that the cocktail of substances stored together in Warehouse 12 created a "very dangerous situation."

"All of those things posed fire and explosive hazards in different ways, so to have them all together is asking for trouble," he said.

'Significant dangers' ignored

Many more questions remain unanswered, such as who originally owned the cargo, what its real destination was and whether it may have been deliberately diverted to Beirut, perhaps on behalf of one of the parties to the war in neighboring Syria, investigators say.

But the documents reviewed by The Post, and interviews with officials and experts involved with the investigation, suggest that neglect, ignorance and stifling bureaucracy played a major part in the tragedy.

Intermittent attempts were made over the years by various officials to remove the stash from the port. Port officials sought authorization from one branch of the judiciary; Customs asked a different branch. The courts said they did not have jurisdiction over the cargo and referred the requests to ministries.

Most petitions to the judges made reference to the fact that the ammonium nitrate was dangerous, and some cited the threat it posed to the safety of port employees. But none made references to the risk it posed to the residential neighborhoods in the vicinity.

Yet the potential danger of the cargo should have been evident from the moment it arrived.

The leaky MV Rhosus, a Moldovan-flagged ship owned by a Russian who operated a business registered in Panama, pulled into Beirut's port on Nov. 16, 2013, carrying about 2,750 tons of ammonium nitrate. "Dangerous substances," said the notice of arrival document, which stated that the ship intended to stay in Beirut only one day to pick up an additional cargo of five shipping containers and eight trucks.

The additional cargo proved too heavy for the Rhosus to take on, according to a statement the captain gave to the media. The ship languished at the port and one month later was seized by Lebanese authorities, who cited a creditor's claim that the ship's charterer owed them money. Six months after that, a judge authorized officials to offload the ammonium nitrate because the ship was in danger of sinking, according to a court order dated June 27, 2014.

"The ship carries hazardous materials that could be dangerous to the port," said the order, signed by Judge Jad Maalouf, in one of the more explicit warnings about the cargo. The government "may transport the dangerous materials to a safe location as long as it guards them and takes all precautionary measures, knowing the significant dangers."

The ammonium nitrate was ­offloaded into Warehouse 12, which was designated for the storage of dangerous materials. It lies only a few hundred yards from the densely packed residential neighborhoods of Gemmayze, Mar Mikhail and Karantina.

Little hope for accountability

Once the ammonium nitrate reached Warehouse 12, it became snarled in the murky limbo of Beirut's notoriously corrupt port.

All the Lebanese political factions maintain a presence at the port and use the facility for smuggling and to extract bribes, said Riad Kobaissi, an investigative journalist with the Lebanese TV channel Al Jadeed.

He suspects officials were never aware of the risks posed. "The ones who are stupid enough to put fireworks beside ammonium nitrate are also stupid enough not to know how dangerous it is," he said. "They dealt with it as if they were not aware."

One line of inquiry being pursued by investigators is whether the ammonium nitrate was being sold off, perhaps in small quantities. A recent order by the prime minister's office to lift banking secrecy laws from 11 officials connected to the port and now under arrest is intended to help officials understand whether they were receiving money from outside sources, said a government adviser familiar with the investigation, who spoke on the condition of anonymity.

The small hole in the wall that the judge ordered to be repaired appeared to be "man-made," according to a senior security official who spoke on the condition of anonymity because he was not authorized to speak to reporters. A photograph shown to The Post showed the gap in the concrete with sacks of ammonium nitrate on the other side.

A video of the sacks taken some time before the explosion and obtained by Al Jadeed shows them strewn haphazardly on the warehouse floor. At least one had been broken open and appeared not to be full.

There is no reason to believe, however, that significant amounts were siphoned off or stolen, experts say. The size of the blast "looked roughly equivalent to the amount of ammonium nitrate that should have been there," said Lewis, the Middlebury arms-control expert.

He calculated that the 2,750 tons of ammonium nitrate would produce an explosion with the equivalent force of 550 to 580 tons of TNT, consistent with the amount of damage seen. "I would be shocked if significant amounts were missing," he said.

Brian Castner, a former U.S. military explosives expert who is now with Amnesty International, reached a similar conclusion, even while acknowledging that small amounts of the ammonium nitrate may have been stolen. Bombs can be built from just a few pounds of the material, he said, noting that the size of the larger bombs he encountered during his service in Iraq averaged 200 to 300 pounds, or a tenth of a ton.

"Between the damage to the grain silo and how far away people were injured and glass was breaking, it generally lines up" with the 2,750 tons of ammonium nitrate originally offloaded into the warehouse, he said.

Whether there will ever be a full accounting of what happened is also an open question. Few Lebanese trust their politicians to countenance a genuine investigation that might implicate them or their associates. "There's not a chance in hell there will ever be accountability," said the person familiar with the investigation. "A typical coverup is on the way."

Forensic investigation of the site to determine the exact cause of the fire is complicated by the fact that it was pulverized by the explosion, with a large watery crater now occupying the space where the warehouse once sat. Fabien Tabarly, director of Nigma Conseil, a security consulting and intelligence firm with offices in Lebanon that analyzed the blast, said the exact trigger for the initial fire may never be known.

Yet all the available evidence also points to the possibility that nothing more than ignorance and ineptitude could explain the tragedy, he said.

"Do not underestimate the power of stupidity," he said. "As crazy as it may seem, as outrageous as it may seem, the most obvious explanation is an accident."

Haidamous reported from Washington. Nader Durgham in Beirut and Asser Khattab in Paris contributed to this report.