The Prime Minister and his wife Lady Victoria Starmer were pictured smiling on the balcony at the Betfred St Leger meeting.
His appearance at the South Yorkshire course came after he returned from Washington DC where he discussed the crises in Ukraine and the Middle East with the US president.
Sir Keir said: “There aren’t many better days out than the races in the sunshine, so it’s a pleasure to be back in Doncaster for the historic St Leger this year.
“My wife has a close connection with the racecourse so the thrill of the St Leger is no stranger to us.
“Good luck to all those involved and to the thousands of racegoers enjoying their day out.”
Lady Starmer is a big horse racing fan and her mother lived in Doncaster.
Amid domestic political difficulties over the squeeze on winter fuel payments and with looming tough decisions in October’s budget, Sir Keir will hope that problems for a horse called Chancellor are not an omen.
Chancellor was strongly fancied to win the Betfred Champagne Stakes but was forced to withdraw after prematurely bursting open his stall and suffering a cut to his mouth.