The law will come into force in July 2020 and cover smartphones, computers and smart televisions.
Proponents of the legislation say it is aimed at promoting Russian technology and making it easier for people in the country to use the gadgets they buy, BBC reports.
But there are concerns about surveillance and fears that firms could pull out of the Russian market.
The law will not mean devices from other countries cannot be sold with their normal software – but Russian “alternatives” will also have to be installed.
The legislation was passed by Russia’s lower house of parliament on Thursday. A complete list of the gadgets affected and the Russian-made software that needs to be pre-installed will be determined by the government.
One of the bill’s co-authors, Oleg Nikolayev, has explained how it could help Russian users.
“When we buy complex electronic devices, they already have individual applications, mostly Western ones, pre-installed on them,” he said, according to Interfax news agency.
“Naturally, when a person sees them… they might think that there are no domestic alternatives available. And if, alongside pre-installed applications, we will also offer the Russian ones to users, then they will have a right to choose.”
But the legislation has faced criticism from manufacturers and distributors in Russia.
The Association of Trading Companies and Manufacturers of Electrical Household and Computer Equipment (RATEK) has said it will not be possible to install Russian-made software on some devices and that the international companies behind the gadgets may leave the Russian market as a result of the law.
Others have raised concerns that the Russian-made software could be used to spy on users.
Russia has introduced tougher internet laws over the last five years, including requiring search engines to delete some search results and calling on messaging services to share encryption keys.
The latest legislation comes just weeks after the country introduced new controls on the internet through its “sovereign internet” law. In theory, the law gives officials wide-ranging powers to restrict traffic on the Russian web.
The Kremlin says it will improve cyber security, but critics fear the government will try to create an internet firewall similar to that in China.