With hundreds of grim-faced farmers looking on, the House voted 268 to 150 yesterday to kill a farm bill that President Carter had promised to veto as inflationary.

As the electronic vote board showed a majority had voted against the bill to raise wheat, corn and cotton prices, there was one yell from the visitors' gallery and the message was passed down the long lines of farmers and their wives waiting in corridors for a gallery seat that "they killed it."

More than three months ago, the farmers of the American Agriculture Movement came to Washington determined to stay until government did something to help them out of a squeeze which they said kept the cost of production above selling prices. They were told there was no chance of a bill's passing, but they worked Capitol Hill day after day and watched their bill pass the Senate and then be approved by a House-Senate conference. Now the bill is dead and it is questionable that another price support bill will be passed this year.

The measure was fought every inch of the way by the administration, which said it would cost several billion dollars, would rise retail food prices by 2 percent and would harm other parts of the agriculture community, such as livestock and diary farmers who buy rather than sell grain.

Carter has said repeatedly, as recently as Tuesday, that he would veto the bill if it reached him. The Senate approved the conference report, 49 to 41, less than the two-thirds needed to override a veto.

Since Carter had promised a veto and thus apparently given members a free, if meaningless, vote for the farmers, the vote was expected to be close.

Rep. Neal Smith (D-Iowa), said the bill should be passed, even if it were to be vetoed, to put pressure on the administration to do something else to help farmers.

"All we are talking about," said Smith, "is whether we veto the bill or should the president? I think we should give the president that opportunity."

But Majority Leader Jim Wright (D-Tex.) called the effort to pass the bill a "meaningless charade . . . this bill has no chance whatever to become law. The president has said he will veto it. The Senate vote shows a veto can't be overridden. Passing the bill won't help the farmer. I'm not going to be a party to that deception."

The bill, which was authored by Sen. Bob Dole (R-Kan.), would have raised price support levels for grain crops and cotton in direct proportion to the amount of land a farmer took out of production.

If a farmer set aside half the acreage he planted, the target price which the government guarantees farmers would rise from $3 to $5.04 a bushel for wheat.

Supporters of the bill denied that it would be inflationary. They said the price a farmer gets has little to do with retail prices. For instance, Smith said, the price a farmer gets for his wheat is less now than three years ago but the retail price of bread is up.

And the farmer gets less for corn than wheat, but the retail price of corn meal and flour are the same. Both cost less in the store than potting soil, which means "they're less than dirt cheap," he said.

Rep. Phillip Burton (D-Calif.), an urban congressman who said he had voted for every farm bill in his 14 years in the House, said he was voting against it yesterday, not on the grounds of inflation but because he accepted the word of experts that it wouldn't work and because it couldn't become law, which would make a "yes" vote misleading.

Rep. Silvio Conte (R-Mass.) called the measure a "boondoggle" and said "consumers and taxpayers don't have the luxury of being able to take three months off" and come to Washington to lobby.

There are pending in both chambers emergency credit bills to make loans to farmers who face bankruptcy.

After the vote, about 2,000 persons supporting the farmers marched along Pennsylvania Avenue from the Capitol to the White House where they rallied for about 45 minutes, D.C. police reported.Police closed PennsylvaniaAvenue between 15th and 17th streets for about an hour to accommodate protesters.