Two military contractors, General Dynamics and Northrop Grumman, agreed on Wednesday to a Pentagon deal that will clear the way for all three of the Navy’s multibillion-dollar stealth destroyers to be built at General Dynamics’ shipyard in Maine, Pentagon and industry officials said.

Northrop Grumman, which had expected to build one of the DDG-1000 destroyers at its shipyard in Mississippi, will contribute major components for each of the vessels. It will also receive contracts for two other destroyers as the Navy restarts production of an earlier model.

Stock analysts said the deal, pushed by Defense Secretary Robert M. Gates, appeared to be a winning proposition for both contractors.

“Mr. Gates delivered a gift to the shipbuilders,” said Loren B. Thompson, a military consultant and the chief operating officer of the Lexington Institute, a research group.