Two handsome buildings, one empty and American, the other bustling and Libyan, stand as testaments in this crumbling capital to recent scoring in the competition between the United States and Libya for dominant influence among the Sudanese people.

The American Cultural Center, where Sudanese used to come to read American newspapers and watch American television news, recently was closed "until further notice." A sign mentions "renovation and maintenance," but the closing followed a bomb threat a week after the U.S. 6th Fleet engaged Libya in the Gulf of Sidra.

Across the Blue Nile in another section of town, a bright green flag snaps in the desert wind above the Libyan People's Bureau, the equivalent of an embassy, which is very much open for business. Outside, hundreds of unemployed Sudanese stand for hours in the sun. They are waiting for an interview inside, a visa and the kind of high-paying job that in the past 12 months has lured nearly 4,000 of their countrymen to Tripoli.

The Libyans were not even players in the game for influence in this vast, politically fragile and strategically situated nation until just over a year ago. That was when a coup brought down the staunchly pro-American government of President Jaafar Nimeri, who had made a point of keeping Libyans out of Sudan. But the new military government soon welcomed Libyans bearing gifts.

Greasing its entry with free oil, foreign employment and, most recently, shipments of military equipment, Libya has transformed its image here from pariah to powerful patron.

Muammar Qaddafi's government has signed a defense agreement with Sudan. A Libyan "unity" delegation sent here last week received a respectful, if noncommittal, reception from the military government and from political leaders awaiting results of the national elections, which ended Saturday. Final results are not expected until later this week.

"There is going to be political unity and economic integration," said Col. Abdel Fattah Younis, a leader of the Libyan delegation, which returned to Tripoli before the U.S. raids on Libya. "This is going to fulfill the strengthening of Sudan's defense capabilities against all elements who expose this unity to danger."

In their propaganda war with the United States, the Libyans now can count on the rhetoric of Sudanese officials who in the past month have vigorously denounced U.S. "aggression."

"There is no doubt about it, the Libyans are riding high right now," said a senior western diplomat who has watched American influence wane here in the past year. "The United States can still lean on Sudan, but it doesn't weigh as much anymore."

The slip in American influence has come despite a year in which U.S. diplomats say they have funneled into Sudan a record $450 million worth of famine aid, economic assistance and military support.

U.S. assistance to Sudan amounted to more than half the $700 million that the World Bank says was given by international donors in 1985 to prevent hundreds of thousands of famine victims from starving and to prop up the country's bankrupt economy.

Sudan's record grain harvest in recent months means that the country will need only about half the $200 million worth of U.S.-supplied famine aid provided last year. A western diplomat here noted that this will further reduce American leverage.

In recent years, the United States has been willing to commit more resources to Sudan than to any African country south of the Sahara. According to a senior western diplomat here, the spending is intended to guarantee that Sudan is a pro-American buffer "of a million square miles that Saudi Arabia and Egypt don't have to worry about."

But after a year of head-to-head competition against Libya, a well-placed western official conceded that the Americans' buffer "has lost a lot of its resiliency. It was Libya that Sudan was supposed to be a buffer against. Now there is a cat among the pigeons."

U.S. sources here say that several Libyans trained and experienced in terrorism are believed to be in Khartoum. U.S. Information Service personnel, who used to work in the now-deserted American Cultural Center, have squeezed into offices in the more heavily guarded U.S. Embassy.

The top military official in the Sudanese government and an influential columnist here have charged in the past month that the United States, in a display of anti-Libyan and anti-Arab spite, is refusing to honor its aid commitments to Sudan.

The U.S. Embassy felt obliged early this month to release a public "clarification" of its aid program. It explained that, except for a brief interruption caused by a failure of Sudan to pay year-old debts, the United States did "disburse assistance under existing agreements."

But Sudanese officials and western diplomats agree that there is a widespread public feeling in Khartoum that the United States has abandoned the government here in its time of need as civil war escalates in the south against rebels armed and supported by the Ethiopian government. Libya, in the meantime, has lent Sudan at least two Soviet-made bombers that have flown raids against southern towns held by rebels of the Sudanese People's Liberation Army.

A reason freqently cited here for the alleged U.S. betrayal of Sudan in the civil war is that Americans are prejudiced against the Moslem north in favor of the predominantly Christian south. The hostilities between the Reagan administration and Qaddafi have fueled northern Sudanese concern over what they see as anti-Arab intentions of the United States.

Sudan's defense minister, Lt. Gen. Osman Abdullar, recently described the U.S. confrontation with the "brotherly Libyans" as a part of an American campaign in the region "that is really against Arabs."