NEW ORLEANS — BP could have ended its massive oil spill in the Gulf of Mexico sooner if it had built a capping stack before the 2010 blowout of its well off the coast of Louisiana, a company executive said under cross-examination Wednesday at a trial over the deadly disaster.

James Dupree, who led BP’s efforts to seal its Macondo well, said engineers didn’t have the equipment they needed to attack this particular well at the time of the blowout and had to formulate several possible solutions “on the fly.” After several other methods failed, BP ultimately used a capping stack to seal the well 87 days after the blowout.

During cross-examination by a plaintiffs’ attorney, Dupree said it would have been relatively inexpensive for BP to build a capping stack before the Deepwater Horizon disaster.

“We certainly weren’t as prepared as we are today,” Dupree said. “We didn’t have the equipment to attack a Macondo-type event.”

BP’s trial adversaries claim the company ignored decades of warnings about the risks of a deep-water blowout and failed to adequately prepare. BP’s attorneys insist the company complied with all government requirements and industry standards for spill preparedness, and neither required the company to have a capping device.

Other companies didn’t have capping stacks, either, and such a device had never been used before 2010 to contain a deep-water blowout.

Asked by plaintiffs’ attorney Brian Barr whether the Macondo well could have been sealed sooner with a pre-built capping stack, Dupree initially answered, “It would depend on what kind of capping stack you built.” But he ultimately agreed with Barr that it could have been possible to cap the well sooner if the device had been assembled before the blowout.

He also said how quickly it could be deployed would also depend on removal of debris and preparing the wellhead to receive the capping stack.

Before the 2010 blowout, BP had a 600-page oil spill response plan that only included one page on “source control.” It called for assembling a team of experts to devise a way to stop a blowout while relief wells are drilled. Dupree said he never referred to the document while he led the response.

During the first few weeks after the spill, engineers focused on two methods for stopping the flow of oil: Capping the well was one option. The other, called “top kill,” involved pumping drilling mud and other material into the Deepwater Horizon rig’s blowout preventer.

With the federal government’s approval, BP employed the “top kill” method in May 2010. But it didn’t stop the flow of oil.

Dupree testified that his decision to proceed with “top kill” was guided by the principle that they shouldn’t do anything that could make the crisis even worse.

“I certainly believed that it was a low risk, we would learn a lot and we would potentially kill the well,” he said.

Plaintiffs’ lawyers claim BP knew the strategy was doomed to fail based on higher flow rate estimates that the company didn’t share with federal officials at the time.

Mark Mazzella, a BP employee who led the “top kill” procedure offshore, testified Wednesday that he had been confident it would succeed.

“We wouldn’t have tried this if we didn’t think it would work,” he said.

BP’s adversaries argue the company could have stopped the spill much earlier than July 15 if it had used a strategy called “BOP-on-BOP,” which called for lowering a second blowout preventer on top of the rig’s failed one.

But BP concluded it wasn’t a viable option because it could have made the situation worse and hampered other strategies if it failed. Dupree said he had feared it could cause an uncontainable blowout on the seafloor.

BP says the capping stack that later sealed the well was specifically designed to land on the well system above the blowout preventer.

Dupree was BP’s first witness for the second phase of the trial, which is divided into two segments. The first focuses on BP’s response to the spill. The second, scheduled to start Monday, is designed to help U.S. District Judge Carl Barbier determine how much oil spilled into the Gulf.

The trial’s first phase ended in April after eight weeks of testimony about the causes of the blowout.