Escalating a crisis in relations, Russia said it was also shutting down the activities of the British Council, which fosters cultural links between the two countries, and withdrawing agreement for Britain to operate a consulate-general in St. Petersburg.
The Russian Foreign Ministry said it was giving the 23 British diplomats one week to leave the country.
The move followed Britain's decision on Thursday to expel 23 Russian diplomats over the attack in the English city of Salisbury which left former Russian spy Sergei Skripal, 66, and his daughter Yulia Skripal, 33, critically ill in hospital.
The ministry said Moscow's measures were a response to what it called Britain's "provocative actions and groundless accusations." It had warned London it stood ready to take further measures in the event of more "unfriendly steps."
Relations between London and Moscow have crashed to a post-Cold War low over the attack, the first known offensive use of a nerve agent in Europe since World War Two.
The Russian Foreign Ministry summoned the British ambassador, Laurie Bristow, to a meeting on Saturday morning in central Moscow at its Stalin-era headquarters during which he was informed of the measures.
Bristow told reporters afterwards that the crisis had arisen after "the attempted murder of two people using a chemical weapon developed in Russia." Britain had only expelled the Russian diplomats after Moscow had failed to explain how the nerve toxin had got to Britain, he said.
"We will always do what is necessary to defend ourselves," the ambassador told reporters.
War of Words
Russia's response was more robust than expected. The closure of the British Council's Moscow office will sever cultural ties, while that of the consulate-general in St Petersburg will end Britain's diplomatic presence in Russia's second city.Russian news agencies cited politicians in Russia's upper house of parliament as welcoming the move to close the British Council, alleging it had been used as a cover by British spies.
British lawmaker Tom Tugendhat, chairman of the Foreign Affairs Select Committee, said the move to close the organisation's office would hurt the Russian people.
"It's a great shame for the Russian people that they're closing the British Council which has done an awful lot to educate Russian people in the English language and to help them get jobs and opportunities around the world," he told the BBC.
Amid calls from British politicians across the spectrum to take further action against Russia, former British ambassador to Russia, Sir Roderic Lyne, told the BBC that Britain should avoid getting dragged into a prolonged show down with Russia.
"I don't think it would be sensible to get dragged down into a mud wrestling battle with a gorilla," Lyne said.
Russia has complained that Britain has failed to provide any evidence of its involvement in the Salisbury attack and has said it is shocked and bemused by the allegations.
Britain has escalated a war of words with Russia over the incident in recent days. On Friday, British Foreign Secretary Boris Johnson said it was overwhelmingly likely that Russian President Vladimir Putin himself had made the decision to use a military-grade nerve toxin to strike down Skripal.
Britain, the United States, Germany and France have jointly called on Russia to explain the attack, while US President Donald Trump has said it looks as if the Russians were behind it.
Russia has said is open to cooperation with Britain, but has refused Britain's demands to explain how Novichok, a nerve agent developed by the Soviet military, was used against the Skripals.
Skripal, a former colonel in the GRU who betrayed dozens of Russian agents to British intelligence, and his daughter have been critically ill since March 4, when they were found unconscious on a bench.
A British policeman was also poisoned when he went to help them and remains in a serious but stable condition.
Russian investigators said on Friday they had opened a criminal investigation into the attempted murder of Yulia Skripal and offered to cooperate with British authorities.
Russia offered some cooperation to British authorities after the 2006 London murder of ex-KGB agent Alexander Litvinenko too.
Britain said the assistance in that case was not enough, and in 2016, a judge-led inquiry concluded that Putin had probably approved Litvinenko's murder, something Moscow denies.
Putin, a former KGB spy who is poised to win a fourth term in an election on Sunday, has so far only said publicly that Britain should get to the bottom of what has happened.