President Reagan scored a major victory yesterday when the Democratic-controlled House reversed itself and voted overwhelmingly to renew aid to rebels trying to overthrow the leftist government of Nicaragua.

After intense administration lobbying, the House voted 248 to 184 to provide $27 million in nonmilitary aid to the rebels over the next nine months.

A third of the Democrats -- 73 -- joined 175 Republicans in supporting the assistance; 177 Democrats and only seven Republicans opposed it. In April, the House narrowly voted down all forms of aid to the counterrevolutionaries, or contras.

In working out the adopted compromise, the White House had to agree to funnel aid to the contras through agencies other than the Central Intelligence Agency and the Defense Department.

But, in another significant move, the House then voted, 232 to 196, against a ban on direct or indirect CIA aid to military or paramilitary forces inside Nicaragua, including the contras. The House has voted four times in the last two years to support such a ban. One now in place expires Oct. 1.

Yesterday's votes will allow Reagan to renew involvement with the contras, ended at the insistence of the House in October. The Republican-led Senate has consistently supported aid to the contras and voted last week to provide $38 million to them over the next two years.

Lawmakers attributed the House turnaround to strong White House lobbying, anger at Nicaraguan President Daniel Ortega for traveling to Moscow immediately after the House voted against all contra aid last month and concern by some southern Democrats that Reagan would accuse them of being "soft on communism."

"There's a shift, a clear shift in the feeling of the House in support for the contras," said House intelligence committee Chairman Lee H. Hamilton (D-Ind.).

In addition to the amendment prohibiting CIA funding for military operations in Nicaragua, sponsored by Rep. Edward P. Boland (D-Mass.), Democrats lost two other efforts to weaken the aid proposal.

One, which would have delayed release of funds for six months, lost, 259 to 172. The other, which would have provided $14 million to refugees outside of Nicaragua and emphasized diplomacy, lost, 254 to 174.

The House later adopted, 271 to 156, the $13.5 billion supplemental spending bill for the rest of 1985, to which the aid proposal was attached.

House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.), who led opposition to aid for the contras, said after the votes that Reagan won only by agreeing to give up military aid, to keep the CIA from handling funds to the rebels and to talk to the Nicaraguan government, and by promising he was not trying to overthrow the Sandinista government.

"The president has spent the last few hours pulling about-faces on every issue of his Nicaraguan policy," O'Neill said. "We in Congress will make sure that he does not reverse himself again, from the new positions he took in order to prevail today."

Before the votes, O'Neill told reporters that Reagan "is not going to be happy until he has our Marines and our Rangers down there for a complete victory. He can see himself leading a contingent down Broadway with paper flying out the windows, with a big smile on his face like a kind of 'Grade B' motion-picture actor coming home the conquering hero."

House Minority Leader Robert H. Michel (R-Ill.), who sponsored the aid proposal, said yesterday that it was very "tepid" and did not go nearly as far as he might like, but was clearly all that the House would support at this point. But the change of heart in the House "is significant," he said. "It's a good win and we're thankful for it."

The $27 million would be released in three installments between now and next March 31. It could be used for food, medicine, clothing and other "humanitarian" items but not weapons, ammunition or other materiel that could "inflict serious bodily harm or death."

The proposal prohibits the CIA or Defense Department from handling the money but allows the intelligence agency to communicate with the contras and exchange information and intelligence.

It also provides $2 million to help implement a possible regional treaty to resolve the conflict and urges Reagan to lift the economic embargo against Nicaragua and suspend nearby military maneuvers if Nicaragua suspends a current state of emergency, announces a cease-fire and negotiates with the "Nicaraguan Democratic Resistance."

Lawmakers said that the House will certainly vote again on the Boland prohibition before it expires and that, despite yesterday's vote, it is likely to continue the prohibition in a modified form.

Supporters of renewing aid argued yesterday that Nicaragua's government is a threat to U.S. national interests and security, that the contras are fighting to restore freedom and that, without them, Nicaragua will become a Soviet-dominated base for subversion of Central America.

"Nicaragua is not another Vietnam; it is another Cuba," Michel said. "The humanitarian aid this amendment provides symbolizes the direct and continuing commitment of the United States to the democratic future of Nicaragua and Central America."

Conservative Rep. Dan Daniel (D-Va.) said: "Last November, we lost an election, 1 to 49. One of the reasons we lost was because we were perceived to be soft on defense." If Democrats voted down the Michel proposal, he said, the public "will think we are soft on communism . . . . We can no longer temporize or compromise with communism on our doorstep.

Opponents of further aid argued that the contras have done little more than strengthen the Sandinistas' resolve, given them an excuse to effect a state of siege and forced them closer to the Soviet Union.

They said that additional aid will lead to U.S. military involvement and that humanitarian aid is a ruse for providing support to an army.

But Rep. William B. Richardson (D-N.M.), who voted against aid last April and switched yesterday, said, "I've been willing to give Daniel Ortega the benefit of the doubt, and that's produced nothing. So I'm willing to give the president a try."