The court announced its verdict on Tuesday, December 10.
Algerian security services arrested both the officials in June on corruption-related charges.
The arrests of Sellal and Ouyahia are part of an anti-corruption drive following the fall of former president Abdelaziz Bouteflika in April.
The Sidi M’Hamed court fined Sellal of $8,000. The court also sentenced former minister of industry Abdessalem Bouchareb in absentia to 20 years in prison, Algerie Presse Service reported.
Ouyahia will also pay a fine of $16,000.
The court also sentenced Former Minister of Industry and Mines Youcef Yousfi to 10 years in prison.
Former Minister of Public Works and Transport Abdelghani Zaalane, however, was acquitted.
The former minister of industry received a sentence of 10 years in prison, while former governor of Boumerdes, Nouria Yamina Zerhouni, received a sentence of five years.
The prosecutor near the court of Sidi M’Hamed requested on Sunday, December 8 a 20-year sentence for the two former prime ministers.
The arrests of officials are led by de facto ruler Gaid Salah, who ordered the arrest of several other senior government officials for corruption-related charges.
The decision to arrest senior officials comes amid continuous protests, which started in Algeria in February to demand a radical change of the “corrupt system.”
In September, an Algerian military court sentenced Bouteflika’s brother, Said Bouteflika to 15 years in prison.