LONDON — President Obama and Queen Elizabeth II on Tuesday toasted the special relationship between the United States and the United Kingdom.

In remarks at the start of a gala state dinner at Buckingham Palace, the queen recalled how the United States “came to the rescue” of Britain in the past and said “the U.S. remains our most important ally” today.

When the two nations stand together, she said, “our people and other people of the good will around the world will be more secure and prosperous.”

In his own toast, Obama thanked the United Kingdom for its solidarity in the 10 years since the Sept. 11, 2001, terrorist attacks, and for the “very heavy sacrifices” it has made while fighting “shoulder to shoulder” with the United States since then. The president and first lady stayed at the palace overnight.

Today, Obama will attend a formal bilateral meeting and news conference with Prime Minister David Cameron and a barbecue at Downing Street for U.S. and British military families and veterans.