The pair were manufacturing explosives so as to launch an attack but had not decided on a target, public prosecutor François Molins said after they were charged on Sunday.
One of them told investigators they were thinking of attacking soldiers involved in France's anti-terror Sentinelle operation.
The plot was uncovered by accident last week when workmen spotted half-concealed bottles, a mysterious white paste, syringes and a set of scales on the bedsit's balcony.
After entering the flat in Villejuif on the outskirts of Pares and finding electrical equipment, they alerted the police.
Molins hailed their "perspicacity" on Sunday.
Bomb-making equipment found
Police found 105 grammes of triacetone triperoxide (TATP) and material for making three to four kilos of the explosive, which is widely used in bombings.
Video on a USB key found at the scene showed tests of the explosive and a computer showed traces of searches for "Islamic State", chemicals, explosives and video games simulating driving of lorries, such as those used in attacks in Nice, Barcelona and Berlin.
The next day more bomb-making materials were found in a lock-up garage rented by Rahmani.
The two men have been named as Franco-Algerian market vendor Ali Mohammed Rahmani, 36, and Frédéric L, a 37-year-old unemployed convert to Islam.
A third man, who was arrested on Wednesday, has been released without charge.
Rahmani was not known to police but Frédéric L was on France's radicalisation watchlist.
In 2015 he had been in contact with Islamic State propagandist Rachid Kassim, who was killed in an air-raid in IS-held territory, according to Molins.
The pair have admitted to considering joining IS in 2015 but dropping the idea because they did not have the money or the contacts to do so easily, police say.