The House swiftly approved and sent to President Reagan yesterday the first foreign aid bill to make it through Congress in four years.

White House officials said Reagan will sign the measure, which authorizes $12.8 billion in spending on foreign aid programs in both fiscal years 1986 and 1987.

The House passed the bill, which was worked out by House and Senate conferees last week, with no debate and by a vote of 262 to 161. The Senate gave voice-vote approval to the measure Tuesday.

The Democratic-controlled House has supported foreign aid bills in the past, but this was the first year since 1981 that the Republican-led Senate did so. For the last four years, the program has snagged in foreign policy disputes and been funded by stopgap spending bills rushed through Congress as each new fiscal year began.

A surprisingly large number of House Republicans -- 110 out of 179 GOP members voting -- supported the bill yesterday. Conservative Republicans generally have voted against foreign aid bills because they oppose sending billions of dollars overseas. But yesterday many switched sides, primarily because the legislation bore an unusually conservative imprint this year.

For similar reasons, a large number of liberal House Democrats voted against the measure. In total, more than one-third of the Democrats opposed the bill.

Among the items that particularly pleased the GOP were $27 million in nonmilitary aid to Nicaraguan counterrevolutionaries, called contras, and a repeal of the decade-old law prohibiting U.S. involvement with military or paramilitary operations against the Marxist government of Angola. In addition, the bill prohibits military aid to the leftist government of Mozambique unless certain political reforms occur. Economic aid would be directed to the private sector.

"This is the best foreign aid bill the White House is ever going to get out of here," said House Minority Whip Trent Lott (R-Miss.), a conservative who nonetheless voted against the bill.

House Foreign Affairs Committee Chairman Dante B. Fascell (D-Fla.) called the bill a "bipartisan measure . . . vital to American interests abroad."

The bill authorizes $15 million each year for humanitarian assistance to Afghan insurgents and $5 million annually in military or economic aid to noncommunist Cambodian rebels.

The bill provides $3 billion a year to Israel and $2.1 billion to Egypt. In addition, Israel gets $1.5 billion in emergency economic assistance and Egypt gets $500 million.

At the same time, the legislation expresses the sense of Congress that Jordan should not receive advanced weaponry from the United States. Reagan would have to certify that Jordan has committed itself publicly to recognizing Israel and to negotiating with Israel before selling Jordan any advanced weapons.

The legislation also contains several provisions designed to deal with terrorism. It provides nearly $10 million a year for antiterrorism aid and gives Reagan authority to ban trade with Libya and any other country that supports terrorism.