The Federal Election Commission ruled yesterday that it is legal for independent candidate John B. Anderson to get bank loans secured by federal funds he may receive after the election.

The 5-to-1 ruling cleared the way for Anderson to negotiate for up to $10 million in loans vital to his slipping presidential campaign.

While President Carter and Ronald Reagan each received $29.4 million in federal funds at the start of the campaign, third-party candidates get money after the election, and only if they have gotten 5 percent of the popular vote.

The election law says loans can be made only if there is assurance that they will be repaid -- otherwise they are illegal corporate contributions. tThe FEC ruled that the chance that Anderson will get funds is sufficient security for the loans, even though there is a risk he will not get the 5 percent.

Anderson's general counsel, Mitchell Rogovin, had requested an advisory opinion from the commission, and on receiving the ruling he said the campaign is pleased at the decision.

He predicted that it will "erase any doubts" about the propriety of the loans being neogtiated or the proposed method of repayment.

Robert Tiernan, one of the three Democrats on the commission, opposed the ruling, saying it is "extremely risky" and would "turn bankers into gamblers" by making them rely on federal funds for which the candidate might never qualify.

This will put 'tremendous political pressure on the bankers" to make the loans, Tiernan said.

The amount of money third-party candidates get depends on the size of the vote. Anderson would get $10 million if he gets 15 percent of the vote, and is said to be seeking up $10 million in loans.