TROY, Vt. (AP) _ On a small dairy farm tucked under the Canadian border, the ''For Sale'' sign has come down. Vermonters, worried that the small farmer might become an endangered species, hope it is the beginning of a trend.

What prompted Gary Jacobs to change his mind and stay on his 100-cow farm was the promise of $5,000 cash this year from the state.

Most of Vermont's 2,700 farmers are eligible for the subsidy under the first such program ever enacted by a state. Farmers have until Wednesday to apply; a maximum of $5,000 will be paid each farmer.

The subsidy was born out of fear that the farms that play such a large role in the heritage of one of the nation's most rural states would soon vanish from the landscape.

The fear was well-founded: 10 percent of Vermont's 3,000 farms went out of business in the past two years.

''It's viewed as being rather revolutionary,'' said Vermont Agriculture Commissioner Ronald Allbee of the new program. ''It's viewed as, 'I can't believe Vermont did it.'''

''I think this is a ray of sunlight to all the dairy farmers in the state of Vermont,'' said Ronald Morrissette of East Randolph, the first to sign up for the subsidy.

The problem facing dairy farmers was simple: The price of milk was falling; costs were rising. Between 1981 and 1987, the price farmers received for their milk declined, in real dollars, from $13.90 to $12.43 per hundred pounds of milk. More than 40 percent of the farms in the state were operating below the break-even point.

The culprit was a federal policy designed to reduce a milk surplus in the West. The policy, farmers said, was ruining dairy farms in New England, where there was a shortage of milk.

As 1988 began, Vermont farmers endured another reduction in the federal price support, the price the federal ensures farmers for their milk, and faced the prospect of more cuts. The state decided to step in.

At first Gov. Madeleine Kunin opposed the one-year $7.5 million program as bad fiscal policy that wouldn't give farmers the long-term help they needed.

But lawmakers and citizens groups - seeing state coffers overflowing from a strong economy - rallied around the subsidy, concerned that the loss of farmers and farmland would change the face of Vermont and remove land treasured for hunting, fishing, trapping and sightseeing.

''They're the custodians of the countryside,'' state Sen. Francis Howrigan, chairman of the Senate Agriculture Committee, said of the farmers.

The subsidy program will pay farmers 50 cents for every hundred pounds of milk they produce up to 1 million pounds, which is more than the average farm produces. It's available to farmers who receive at least half their gross income from farming, make less than $32,000 a year, and belong to a milk cooperative or an 11-state dairy cartel that's trying to win a higher milk price for Northeast farmers.

The program faces a legal challenge from a group of farmers who say the program discriminates against those few who do not belong to co-ops.

The Legislature this year also enacted some long-term help for farmers that will give them big breaks on their property taxes in future years. The state will pay up to approximately 90 percent of farmers' local property taxes if they agree to continue farming.

The tax program covers all non-dairy farmers this year; next year, when the dairy subsidy is eliminated, it will apply to dairy farmers.

But lawmakers and farmers say the state cannot afford to continue its $7.5 million subsidy and that the true solution can come only from the Congress.

''It's the finger in a dike that is getting an ever-wider fissure,'' said New Hampshire Agriculture Commissioner Stephen Taylor. ''I think we're in a dire situation, and I don't think the state of Vermont has the resources to carry that farmer for a long period of time.''

Jacobs expects to triple the value of his $5,000 payment from the state by using it to grow feed, one of his rapidly rising expenses.

''It's going to make a difference, and it gives you a chance,'' he said, surveying the corn field that lies in the shadow of Jay Peak, a popular ski area. ''It may turn around.''