On an October day last year, with Lieutenant Colonel Fred Schenk at the controls, the plane glided toward a ship off the Atlantic coast and then, its engine rotating straight down, descended gently to the deck at 7 feet a second.
There were cheers from the ship's crew members, who "were all shaking my hands and smiling," Schenk recalled recently.
The smooth landing helped save that model and breathed new life into the F-35 program, the most expensive weapons system in military history. But while Pentagon officials say the program is making progress, it begins its 12th year in development years behind schedule, troubled with technological flaws and facing concerns about its relatively short flight range as possible threats grow from Asia.
With a price tag potentially in the hundreds of billions of dollars, the jet is likely to become a target for budget cutters. Reining in military spending is on the table as President Barack Obama and Republican leaders in Congress look for ways to avert a fiscal crisis. But no matter what kind of deal is reached, military analysts expect the Pentagon budget to decline in the next decade as the war in Afghanistan ends and the military is required to do its part to reduce the federal debt.
Behind the scenes, the Pentagon and the F-35's main contractor, Lockheed Martin, are engaged in a conflict of their own over the costs.
The relationship "is the worst I've ever seen, and I've been in some bad ones," Maj. Gen. Christopher Bogdan of the Air Force, a top program official, said in September.
The F-35 was conceived as the Pentagon's silver bullet in the sky - a state-of-the art aircraft that could be adapted to three branches of the military, with advances that would easily overcome the defences of most foes. The radar-evading jets would not only dodge sophisticated anti-aircraft missiles but would also give pilots a better picture of enemy threats.
But the aircraft instead illustrates how the Pentagon can let huge and complex programs veer out of control and then have a hard time reining them in. The program nearly doubled in cost as Lockheed and the military's own bureaucracy failed to deliver on the most basic promise of a three-in-one jet that would save taxpayers money and be served up speedily.
Lockheed has delivered 41 planes so far for testing and initial training, and Pentagon leaders are slowing purchases of the F-35 to fix the latest technical problems and reduce the immediate costs. A helmet for pilots that projects targeting data onto its visor is too jittery to count on. The tail-hook on the Navy jet has had trouble catching the arresting cable, meaning that version cannot yet land on carriers.
And writing and testing the millions of lines of software needed by the jets is so daunting that Bogdan said, "It scares the heck out of me."
The jets would cost taxpayers $396 billion, including research and development, if the Pentagon sticks to its plan to build 2,443 by the late 2030s. That would be nearly four times as much as any other weapons system and two-thirds of the $589 billion the United States has spent on the war in Afghanistan. The military is also trying to figure out how to reduce the long-term costs of operating the planes, now projected at $1.1 trillion.
For years, the problems with the F-35 raised few red flags, as money flowed freely after the 2001 terror attacks and enthusiasm for a three-in-one jet blinded officials in the Clinton and Bush administrations and in Congress to its overly ambitious design. Now, unless the Pentagon can substantially reduce the price of each plane, analysts say, it may be lucky to buy 1,200 to 1,800.
Robert J. Stevens, the chief executive of Lockheed Martin, said company officials were "working as aggressively as we can" to fix the problems and cut costs.
Vice Adm. David Venlet, who now runs the program at the Pentagon, said he was confident that "good old-fashioned engineering is going to lick" the flaws. But he declined to predict how many planes would be bought.
The roots of the problems go back to the mid-1990s, when military officials pitched the F-35 as simple and affordable, with the three versions sharing 70 to 80 per cent of their parts. The planes would also be versatile, capable of fighting other planes but focused mainly on attacking ground targets.
Almost immediately, the project proved to be incredibly complicated. Lockheed's initial designs were late and had to be redone, delaying the manufacture of parts for the test models. While most military programs start building before all the testing is done, the Pentagon took that to an extreme, starting production of the F-35s in 2007, before flight tests had even begun.
Frank Kendall, who became the Pentagon's top weapons buyer in May, has said that diving into production so soon amounted to "acquisition malpractice."
With the Iraq and Afghanistan wars raging, Robert M. Gates, who was then the defence secretary, did not deal with the problems with the F-35 until late 2009 and early 2010, when he fired the general in charge and brought in Venlet, a former fighter pilot who had overseen testing of Navy aircraft.
Venlet's first move was to bring in technical experts from the services who had been shut out of the program.
Another method that he chose to assert control is decidedly low-tech: printouts of charts, hung from whiteboards on all four walls of a "war room" in the F-35 offices near the Pentagon.
"It looks maybe a little dinosaur-like," he acknowledged, standing near cutout plane shapes tracking the flow of parts into Lockheed's mile-long plant in Fort Worth, Texas. "But you know what? It works."
Military officials said the testing has picked up substantially at the Patuxent River Naval Air Station here and other bases. Still, the overlap between testing and production remains a serious problem.
Lockheed argues that the government's estimates of what the F-35s should cost now are too low and that the program was far riskier than the military said it would be. Only 20 to 30 per cent of the structural parts ended up in common, although the models will share engines and software. Lockheed officials also noted that commercial plane makers had run into delays with their most innovative planes, Boeing's 787 Dreamliner and Airbus' A350.
Lockheed is fixing the most glaring problems. But the "gorilla in the room," Bogdan said, is testing and securing the 24 million lines of software code for the plane and its support systems, a mountain of instructions that goes far beyond what has been tried in any plane.
Still, if the military and Lockheed can "hold each other accountable," he said, "we've got a shot at getting this done."