This West African nation begins its third decade of independence this month still charting what President Leopold Sedar Senghor calls a "middle way" between capitalism and socialism.

During the past 20 years, the former French colony has developed a unique kind of political system that includes organized political opposition, the absence of tribal strife and a degree of public criticism of the government that is a singular rarity in Africa.

Senegal's record of political stability and tolerance is frequently credited to its wily, intellectual 74-year-old president, whose skillful manipulation of opposition, religious and tribal interests have left him in virtually complete control of the country.

But partly because of weather and rapidly rising energy costs, Senegal's economy is experiencing serious difficulties. Critics charge that these are exacerbated by mismanagement, inefficiency and corruption in an unwieldy system of government-owned and semipublic enterprises.

Moreover, the Senghor government faced its first public challenge in a decade when students in the southern city of Ziguinchor staged a three-day riot in January, burning the mayor's house, two hotels, and their principal's home and destroyed several stores.

The riot erupted when a planned protest of educational conditions got out of hand and one student was killed in the melee. It left the government "very nervous because police were unable to contain the students," one Western source said.

Abdoulaye Wade, leader of the political opposition, has criticized Senghor's economic policy for its heavy reliance on a single cash crop -- peanuts -- and on phosphate exports.

One bright spot in the country's economic picture is its growing tourist trade, but critics argue that the hotel industry is in the hands of foreigners and that Senegal benefits little from the influx of thousands of European visitors.

"We think that after independence we should have concentrated on agricultural development," Wade said in an interview. "Now we have a peanut and phosphate export model economy with a weak agricultural base and deteriorating terms of trade. We are also tied up with debts."

Senghor, Wade continued, has given away "the best beaches" to French interests and "the Senegalese cannot have access to the best sites." He said that "imported capital makes us dependent" on foreign countries and that Senghor is "verbally supporting agricultural development" but doing nothing to aid it.

In the early 1970s, when phosphate prices were high, Senegal borrowed heavily in international money markets. Today, the government is $723 million in debt, an amount that is roughly 40 percent of the country's gross national product for 1978.

Replying to Wade's charges, Senghor said in an interview before he departed for a visit to Washington this week that the opposition leader "uses anything he can lay his hands on," and accuses the government at times of "nationalizing everything and at other times of being in the arms of capitalists."

Despite difficulties, he said, "the Senegalese economy has not collapsed." Senegal's problems are endemic to the developing countries of Africa.

"I say so because we have not properly assimilated the spirit of method and organization which characterizes" the West, he continued. "We pay lip service to things and we are not sufficiently organized.

"You see, the disadvantage of the capitalist system is that it gives too much importance to the private sector and the disadvantage of the communist societies is that they nationalize everything lock, stock and barrel."

He will, he said, continue "a middle course between out-and-out capitalism and socialism."

Senghor, a Catholic in a country where 80 percent of the 6 million people are Moslem, has been able to rule through an extensive system of patronage also involving the religious leaders of Senegal's powerful Moslem Brotherhood. He has also adopted the role of a neutral mediator in inter-Islamic squabbles.

The source of Senghor's political strength is his Socialist Party's base in the countryside where 75 percent of Senegal's population lives.

Under a recently amended constitution, each of the four political parties is assigned a definite ideological position that cannot be changed. If the parties deviate from it -- something Senghor presumably is left to interpret -- the parties may be legally disbanded.

Only one of the opposition parties, Wade's Senegalese Democratic Party, is represented in parliament. It has 16 of the legislature's 100 seats. The radical Marxist-Leninist party and the rightist Republican Party are not represented, but are allowed to field candidates in the elections.

"We have limited the number of parties deliberately," Senghor said, "to the four [political] trends that exist in Senegal."

Critics say that in practice Senegal is a one-party state with authority concentrated in Senghor's hands.The ruling party has displayed authoritarian tendencies with Senghor frequently intervening to protect political minorities.

This, according to Wade, is the clue to Senghor's strength. He has been able to ensure the country's political stability, Wade added, "by always protecting the minorities and having them rely on him for that protection."