The House last night passed, 221 to 147, a $5.2 billion military and economic foreign aid authorization bill for next year after making a dramatic turnaround and voting to continue economic aid to Nicaragua by 243 to 144.

The House cut the bill reported from committee by $310 million, leaving it only $87 million below the administration's request -- unusual support for the chronically unpopular program in a year of budget-balancing efforts.

No cuts were made in aid to Israel or Egypt.

Approval of the aid to Nicaragua was in part a result of a lobbying trip to Washington by a member of the ruling group of that Central American country. The bill now goes to the Senate.

Last winter a bill authorizing $75 million in aid to help Nicaragua recover from civil war squeaked through the House by only five votes. And last week the House voted 267 to 105 to cut $5.5 million in military aid to Nicaragua out to bill. Opponents of the aid argue that Nicaragua has come under communist domination and the aid would be money lost. Supporters contend it is worth the risk to try to help Nicaragua build institutions of freedom

During this last week, Arturo Cruz, a banker and moderate new member of the ruling junta, was in Washington meeting with members of Congress. Comments made in yesterday's debate indicated he had impressed many members, including Speaker Thomas P. (Tip) O'Neill Jr., with assurances that the vast majority of the Nicaraguan people want to live in freedom, not under the domination of Cuba or the Soviet Union.

House leaders pulled out all the stops to keep the Nicaraguan aid in the bill. O'Neill, who said last month he needed to be shown Nicaragua was worth saving, took the floor for what he said was his first speech on foreign aid in 28 years to ask the House to defeat the amendment that would have striken the money from the bill.

Majority Leader Jim Wright (D-Tex.) also appealed personally to members to save the Nicaragua money. He said President Carter had asked him to lead a delegation to Nicaragua this weekend to seek assurances from government leaders there that free elections will be held.

After beating back the effort to forbid aid, managers of the military and economic foreign aid bill reluctantly accepted without a fight amendments earlier written into this year's $75 million aid authorization bill that would stop aid if Nicaragua engages in a pattern of human rights violations. It also directs the president, in providing aid, to take into account government interference in the right of labor to organize and in press and religious freedoms.

The $75 million, though authorized, has not been made available because this year's foreign aid appropriation bill has been frozen pending adoption of a new higher spending ceiling in the budget resolution, which House and Senate conferences are fighting over.