US President Barack Obama has ordered the expulsion of 35 Russian diplomats and sanctioned Russian intelligence officials who his government believes were involved in hacking US political groups in the 2016 presidential election.

The measures, taken during the last days of Mr Obama's presidency, mark a new low in US-Russian relations which have deteriorated over serious differences on Ukraine and Syria.

"These actions follow repeated private and public warnings that we have issued to the Russian government, and are a necessary and appropriate response to efforts to harm US interests in violation of established international norms of behavior," Mr Obama said in a statement from vacation in Hawaii.

It was not immediately clear whether President-elect Donald Trump, who has repeatedly praised Russian President Vladimir Putin and nominated people seen as friendly toward Russia to senior administration posts, would seek to roll back the measures once he takes office on 20 January.

Mr Obama is seeking to deter Russia and other foreign governments from leveraging cyber attacks in the future to meddle in US politics, former officials and cyber security experts said.

Mr Obama has been under growing pressure from within his own administration and lawmakers of both political parties to respond more forcefully to the cyber attacks, which included leaked emails of Democratic Party operatives that became part of the media coverage in the campaign for November’s presidential election.

A spokesman for Mr Putin said the sanctions would harm relations between the two countries.

Dmitry Peskov said Mr Putin would order an "appropriate" retaliation to the sanctions.

In a conference call with reporters, he added that doubted the effectiveness of the measures as the current US presidential administration was stepping down in three weeks.

Russia has categorically rejected the hacking claims and has pledged "adequate reprisals" over the sanctions.

Mr Obama sanctioned two Russian intelligence agencies, the GRU and the FSB, four GRU officers and three companies "that provided material support to the GRU's cyber operations.

Mr Obama said the State Department declared as "persona non grata" 35 Russian intelligence operatives and is closing two Russian compounds in New York and Maryland that were used by Russian personnel for "intelligence-related purposes".

The State Department originally said the 35 were diplomats.

A senior US official told Reuters the move would affect the Russian embassy in Washington and consulate in San Francisco.

The Russians have 72 hours to leave the US, the official said.

Access to the two compounds, which are used by Russian officials for intelligence gathering, will be denied to all Russian officials as of noon tomorrow, the senior US official added.

"These actions were taken to respond to Russian harassment of American diplomats and actions by the diplomats that we have assessed to be not consistent with diplomatic practice," the official said.

The State Department has long complained that Russian security agents and traffic police have harassed US diplomats in Moscow, and US Secretary of State John Kerry has raised the issue with Mr Putin and his foreign minister, Sergei Lavrov.

"By imposing costs on the Russian diplomats in the United States, by denying them access to the two facilities, we hope the Russian government reevaluates its own actions, which have impeded the ability and safety of our own embassy personnel in Russia," the official said.

The US official declined to name the Russian diplomats who would be affected, although it is understood that Russia's ambassador to the US, Sergei Kislyak, will not be one of those expelled.