RIYADH, Saudi Arabia — Russia and the U.S. agreed Tuesday to start working toward ending the war in Ukraine and improving their diplomatic and economic ties, the two countries’ top diplomats said after talks that reflected an extraordinary about-face in U.S. foreign policy under President Donald Trump.

In an interview with The Associated Press after the meeting, U.S. Secretary of State Marco Rubio said the two sides agreed broadly to pursue three goals: to restore staffing at their respective embassies in Washington and Moscow, to create a high-level team to support Ukraine peace talks and to explore closer relations and economic cooperation.

He stressed, however, that the talks — which were attended by his Russian counterpart, Sergey Lavrov, and other senior Russian and U.S. officials — marked the beginning of a conversation, and more work needs to be done.

Lavrov echoed Rubio’s remarks and told reporters that “the conversation was very useful.”

“We not only listened, but also heard each other,” he said.

Trump’s national security adviser, Michael Waltz, and special Mideast envoy Steven Witkoff joined Rubio at the table, along with Lavrov and Russian President Vladimir Putin’s foreign affairs adviser, Yuri Ushakov.

No Ukrainian officials were present at the meeting, which came as the beleaguered country is slowly but steadily losing ground against more numerous Russian troops in a grinding war that began nearly three years ago.

Ukrainian President Volodymyr Zelenskyy said his country would not accept any outcome from the talks since Kyiv didn’t take part, and he postponed his own trip to the kingdom scheduled for today.

European allies have also expressed concerns that they are being sidelined.

Trump showed little patience for Ukraine’s objections to being excluded from the talks. He said repeatedly that Ukraine’s leaders never should have allowed the war to begin, suggesting the country should have been willing to make concessions to Russia before the 2022 invasion.

“Today I heard, ‘Oh, well, we weren’t invited.’ Well, you been there for three years. You should have ended it three years” ago, Trump said during a news conference at his Florida residence. “You should have never started it. You could have made a deal.”

Ties between Russia and the U.S. have fallen to their lowest level in decades in recent years — a rift that has been widening ever since Russia illegally annexed Crimea from Ukraine in 2014 and only worsened after Moscow’s full-scale invasion.

The U.S., along with European nations, imposed a raft of sanctions on Russia in an effort to damage its economy. And embassies in Washington and Moscow have been hit hard by expulsions of large numbers of diplomats, as well as other restrictions.

Rubio said Tuesday that ending the war in Ukraine could “unlock the door” for “incredible opportunities” to partner with the Russians on issues of common interest “that hopefully will be good for the world and also improve our relations in the long term.”