The Defense Department has agreed to pay Ford Aerospace and Communications Corp. as much as $200 million to keep open the production line for the DIVAD antiaircraft gun, a controversial weapons program that Defense Secretary Caspar W. Weinberger has said he may cancel next spring.

The money will be used to continue purchasing parts for the gun and keep Ford's many subcontractors in business in case Weinberger decides to continue production. If performance tests persuade him that more DIVAD guns should not be purchased, the $200 million will not be retrieved, officials said. The Army already has spent $1.5 billion on the Divisional Air Defense program.

Army officials said yesterday that it is worth maintaining "an intravenous line" of funds into the program because they believe that DIVAD will survive Weinberger's scrutiny. It would be far more expensive, they said, to shut down production entirely and then resume it next spring.

"The reason this action is being taken is because we have confidence in the program," Army spokesman Maj. Don Maple said. "This is a good deal for the government and a good deal for the taxpayer because Ford has agreed not to exercise its right to increase costs."

Weinberger informed Congress in September that he had reduced his request for DIVAD for fiscal year 1985 to $100 million, from an original request of $515.8 million. His request came after the first DIVADs delivered did not live up to expectations, missing their targets in tests and breaking down too frequently.

Weinberger said the $100 million would be spent only for "long lead items" and would not be obligated unless the DIVAD survived rigorous tests next summer.

"If those tests are not successful, the $100 million, of course, will not be spent," Weinberger wrote in his letter to Congress.

At the time, however, the Army still had in the bank $604.9 million that Congress had appropriated for the DIVAD for fiscal year 1984, which had not been spent. The $200 million figure announced yesterday will come from that account, officials said.

The DIVAD gun is a twin 40mm cannon mounted on a converted M48A tank chassis and guided by a radar system modified from the F16 fighter jet. It is intended to travel to the front of a battle line and protect tanks, armored personnel carriers and infantry from attacking helicopters.

In performance tests, the DIVAD has had trouble finding its intended target, in one case locking onto a latrine fan instead. In a recent demonstration of the DIVAD at Fort Bliss, Tex., arranged without the Pentagon's permission, the gun required three tries to knock down a drone helicopter that was flying slowly, in a straight line and well inside the gun's intended range.

The Army has spent $1.5 billion on the DIVAD, for which Ford has promised to deliver 146 of the weapons. Twenty-one have been delivered, Maple said, and deliveries will continue during the coming months.

The Army says it hopes to buy 614 of the guns for $4.5 billion. Although many in Congress assumed that Weinberger's action in September killed the program, Army officials said they expect the DIVAD to survive.

Because the contract is being stretched, however, Ford could have raised the price on 117 DIVADs that remain to be paid for in the initial fixed-price agreement. Army officials said that, in return for the payment of up to $200 million, Ford promised not to raise the price of those units.