WASHINGTON — He started the day with cheers and ended it with jeers. Hours after announcing the death of one of the world’s most notorious terrorists, President Trump found little love at the World Series.

In his first appearance at a Major League Baseball game since taking office, Mr. Trump was not invited to throw the first pitch when he showed up Sunday night at Game 5 between the Washington Nationals and the Houston Astros. Instead, when he was shown on the stadium’s large screen, the crowd booed robustly and began chanting, “Lock him up!” In the upper decks, fans held up a giant “Impeach Trump!” banner.

The unfriendly reaction may explain his reluctance to take himself out to the ballpark until now. Although he has boasted of his time as team captain for the baseball squad at the New York Military Academy and in the past happily offered regular commentary on the game, before Sunday Mr. Trump had never attended a professional baseball contest while living in the White House, an unusually prominent break from the national pastime for a sitting president.

Conceding nothing to the moment, Mr. Trump arrived at the park dressed in his trademark dark suit, white shirt and red tie. Perhaps knowing that he might not draw a warm welcome in a city where he received just 4 percent of the vote in 2016, Mr. Trump brought his own fan club in the form of a dozen Republican members of Congress who rode over from the White House in a minibus included in his motorcade.