The Tunisian government declared a nationwide state of emergency and ordered the Army into the streets of Tunis today, as rioting over sharply increased bread prices spread to the capital.

Smoke billowed over the city at sunset from burning cars and buildings set ablaze by crowds of angry youths and workers. Streets were deserted and littered with debris from looted stores.

The violence began Thursday in the country's poorest southern and western regions when the government ended long-standing price subsidies on grain products in an effort to reduce its heavy budget deficit.

By yesterday, as many as 25 people had been killed in three southwestern provinces, many shot to death by Army and police forces, according to sources in Tunisia's labor and political opposition movements. A government communique yesterday confirmed four deaths, without suggesting their causes.

Witnesses said many people were injured in today's riots here in the capital, but there were no confirmed reports of deaths.

Riots and demonstrations occurred today in many other cities throughout Tunisia, according to local sources reached by telephone from Tunis.

The latest protests have taken a general antigovernment tone, according to Tunisian and diplomatic observers.

A curfew was declared in Tunis from 6 p.m. until 5 a.m., and groups of more than three persons were not permitted in the streets during daylight hours. Troops and police were authorized to shoot if necessary to prevent anyone who disobeyed orders from fleeing.

The violence here began in the morning, with confrontations between rock-throwing crowds and helmeted riot police who fired tear gas and warning shots.

Late in the afternoon, tanks growled through the city to take up positions around government buildings, including the palace of President Habib Bourguiba, in suburban Carthage.

President Bourguiba returned to Tunis in the afternoon, after having flown to his hometown of Monastir this morning to begin celebrations of the 50th anniversary of his Destourian Socialist Party, which has held power under his leadership since Tunisia's independence in 1956.

Prime Minister Mohammed Mzali said late tonight that the riots were aimed at "toppling the government." In a television address, Mzali gave the government's first detailed reaction to the riots, saying that unspecified persons had led Tunisian youths to acts of "pillage aimed at creating a climate of terror, instablity and doubt."

A leading opposition party, the Movement of Social Democrats, said the riots were "a popular response to the impossibility of bearing the burden of the new bread prices," which increased by 125 percent over the old price, making a loaf of bread that formerly cost about 8 cents now sell for 18 cents.

The party denounced the government's response to yesterday's rioting, calling it "brutal."

Most daily newspapers and the state press agency have ignored the rioting, leaving Tunisians to learn the news from European broadcasts and telephoned reports from friends in other Tunisian cities.

The government decision to end the subsidies on grain products was announced in October. In 1982, the grain subsidy cost the government $143 million, a quarter of its budget deficit.

The subsidies had held bread prices virtually unchanged for 20 years, and the artificially low price led to massive waste. On the streets of Tunis, window sills and mailboxes are commonly littered with half-eaten loaves of bread, as religious tradition forbids throwing it on the ground.

Tunisian and diplomatic political observers said the bread price rise had ignited widespread frustration among Tunisia's poor and its youth.

"It's no surprise that the violence began in the southwest. The interior regions of Tunisia lag far behind the coast in the level of economic development and opportunities," a diplomat said.

Government figures show an unemployment rate of 20 percent for the three provinces where the rioting began. But those statistics count as employed anyone who has worked more than one day a month, the diplomat said.

Analysts said Tunisia's high unemployment is its greatest economic and political challenge.

"This is a population which is relatively better educated and relatively younger than some others in the Third World. And, having made good economic progress in recent years, they have pretty high expectations. So the Tunisian population is relatively demanding and potentially more volatile than, say, in Chad or elsewhere," a western economic analyst said.

The opposition Movement of Social Democrats said the government had decided on the price hikes "unilaterally" without consulting Tunisia's powerful labor movement or other "national groups."

The oppositon party said government measures aimed at easing the impact of the price rise were inadequate.

The price hikes aroused a sharp controversy within the Tunisian labor federation, which has said it was studying the issue before taking a position.