A close ally of Bouteflika, Ouyahia is the most senior figure to be detained since mass protests broke out earlier this year demanding the removal of the ruling elite and their prosecution.
Ouyahia, who left the government in March as part of a cabinet reshuffle, is being investigated over corruption cases including "awarding illegal privileges", state television reported.
His former transport minister, Abdelghani Zaalane, was also placed in custody in connection with a corruption investigation.
Bouteflika stepped down on April 2 under pressure from the army and protests that broke out on Feb. 22. Zaalane had been named campaign manager for Bouteflika for an April 18 presidential election, which was cancelled.
The army is now the most powerful institution and its chief Ahmed Gaed Salah has urged the judiciary to investigate all people suspected of being involved in corruption.
Several senior figures including another former prime minister, Abdelmalek Sellal, and eight former ministers appeared last month in a court in Algiers on suspicion of corruption.
Bouteflika's youngest brother, Said, and two former intelligence chiefs have been placed in custody by a military judge for "harming the army's authority and plotting against state authority".
Several prominent businessmen, some of them close to Bouteflika, have been detained pending trial.
Protesters are now seeking the departure of interim President Abdelkader Bensalah and Prime Minister Noureddine Bedoui, both seen as part of the elite that has ruled the North African country since independence from France in 1962.
Ouyahia is the leader of Algeria's second largest party, the Democratic National Rally (RND), which supports the interim government but is not part of it.
Authorities have postponed a presidential election previously planned for July 4, citing a lack of candidates. No new date has been set for the vote.
(FRANCE 24 with REUTERS)