Grateful for Algeria's key role in freeing American hostages from Iran, the Reagan administration is considering sale of C130 Hercules military transport planes to the revolutionary Arab nation, official sources said yesterday.

The proposed sale, reported still under review, would reverse longstanding U.S. policy barring military sales to Algeria, whose militant Third World positions often have put it in conflict with the United States on issues ranging from the Arab-Israeli conflict through the Western Sahara war to international terrorism.

Although it comes against the backdrop of friendlier U.S. attitudes toward Algeria since the hostage crisis, the proposal also grows from recent signs from Algeria that it is interested in better relations and a hope here that such a sale could help wean the Algerians away from their military supply relationship with the Soviet Union, a diplomatic source explained.

As described by the sources, the proposal involves a half-dozen of the workhorse military transports. Even this small number is seen as an important symbol of U.S. gratitude, however, because according to a State Department spokesman the sale would become the first of U.S. military equipment to the Algerian government and the C130 has been used in the past as a first step toward military relationships with formerly hostile Arab governments such as that of Egypt.

Three L100 transports, a civilian version of the C130, have been sold to the Algerian national airline, Air Algerie, and the Algerian armed forces have purchased several Beech 34C search-and-rescue craft. Neither deal was considered military, however, and both were surrounded by tight restrictions, the spokesman said.

In addition, the proposed sale of C130s would mark at least a shift in nuance in Washington's policy on the Western Sahara war, in which Algeria is the main backer of the Polisario guerrillas fighting a hit-and-run desert campaign against Morocco for autonomy in the former Spanish Sahara.

Although the United States has professed neutrality in that conflict, it has been a main supplier of arms to Morocco for two decades while abstaining from similar sales to Algeria. Within days of the hostages' release last month, in fact, the Reagan administration let it be known that it plans to sell more than 100 U.S. M60 tanks to Morocco.

This sale would come on top of a Carter administration decision last March to sell Morocco about $232 million worth of reconnaisance planes and helicopters. The first deliveries of OV10 Bronco reconnaisance planes under that deal were approved soon after Secretary of State Alexander Haig Jr. took office.

These sales have long been a sore point with the Algerians and diplomatic analysts were predicting even as Algeria was mediating between Iran and the United States that the Algerians could hope for more favorable treatment as a result of their help.

The sale of Hercules transport planes to Algeria now, diplomatic sources said, could be interpreted as a vote of confidence in as well as a gesture of thanks to the government of President Chadli Benjedid. Algeria's Arab nationalist stance has been less strident since Benjedid took over in February 1979 after the death of the more radical President Houari Boumediene.

Moreover, the sources said, the C130's conceivably could be used in the Sahara war or in other African trouble spots, although an obvious purpose would be to ferry heavy equipment between Western Europe and Algeria. Since its independence in 1962 at the end of a bitter war, Algeria has obtained most of its arms from the Soviet Union and France, its former colonial ruler.

Despite the C130's potential for long-range intervention, the Defense Department is understood to have approved the proposed sale from the military point of view. The idea is still under review in the State Department and the White House, the sources said.

One consideration could be Algeria's past role as a haven for airline hijackers and other terrorists. Libya's attempt to purchase C130s from the United States has been held up, for example, because of an official determination that it aids terrorists.

The sale to Algeria would be strictly cash-and-carry, the sources said. While Congressional notification is necessary, the deal thus would not fall under restrictions of the Foreign Assistance Act.

Despite contradictory and even hostile differences on a number of issues, the United States and Algeria have maintained active commercial relations. Algeria is a major importer of U.S. technology and its oil and gas exports to the United States amount to nearly $10 billion a year. A dispute that has held up negotiations for new natural gas contracts between the United States and SONATRACH, the Algerian government petroleum company, is said to revolve around financial and commercial differences rather than diplomacy.