The Treasury Department yesterday gave the presidential campaign of Ronald Reagan a check for $29.4 million after an attempt by Democrats to block the move failed.

William Casey, Reagan's campaign manager, accepted the check with a smile and promptly ordered campaign, treasurer Ray Buchanan to deposit it in the nearest branch of the Riggs National Bank.

"I get nervous holding that much money in my hand," Casey said.

He then walked out of the Treasury Department Annex, across Pennsylvania Avenue from the White House, saying, "See you in four years."

President Carter's reelection committee had sought a temporary restraining order to block issuance of the check on grounds that independent groups that plan to pump millions of dollars into the Reagan campaign are violating federal election laws.

But the U.S. Court of Appeals here refused early yesterday to grant the order. Within minutes, the Federal Election Commission -- made up of three Democrats and three Republicans -- certified Reagan as eligible for the $29.4 million payment.

The court ordered that a special panel be established "at the earliest possible time" to hear two suits challenging the legality of the independent groups backing Reagan.

If the courts find the independent expenditures illegal, the FEC said Reagan will have to refund the federal money. But it insisted that nothing has occurred so far to justify denying Reagan the funds.

The battle over distribution of the money was seen as the opening salvo in what is expected to be a long and bitter campaign for the presidency.

By law, the nominees of both major parties are to receive $29.4 million in public money this year, raised by an income tax checkoff, to finance their general election campaigns. They are prohibited from receiving private contributions.

A 1976 Supreme Court ruling allows independent groups or individuals to support candidates as long as they act independently of the campaigns. These groups are at the center of the current controversy.

At least five groups have announced plans to raise between $40 million and $60 million in Reagan's behalf. No such groups have formed to aid Carter in his bid for reelection.

Carter forces claim the Reagan groups are closely allied with the Republican's campaign, in violation of the law. The Carter backers have filed a complaint with the FEC and have written to hundreds of broadcasters warning them not to accept ads paid for by the independent groups because of possible legal complications.

As an example of the ties between the Reagan camp and the independent groups, the Carter forces cite a television interview last week in which Sen. Jesse Helms (R-N.C.), who heads one of the independent groups, was asked if he had any interaction with Reagan. Helms replied: "I've had to sort of talk indirectly with (Sen.) Paul Laxalt (R-Nev., Reagan's national campaign director) and hope that he'd pass it along, and I think the messages have gotten through."

Both the Reagan and Carter campaigns expressed satifaction with yesterday's developments.

Casey said he was grateful that Carter's "clumsy attempt to disenfranchise a large portion" of the public -- namely. Reagan supporters -- had been "rebuffed" by the FEC and the court.

The Carter campaign claimed it had made "a considerable breakthrough" in getting the appeals court to order an expedited hearing on the question of independent campaign groups.

"We are confident that these issues, which have critical relevance to both the ground rules and outcome of the fall election, now will be fully and fairly resolved in a timely fashion," said Robert S. Strauss, Carter's national chairman.