President Trump's low-profile appearance Sunday night at Game 5 of the World Series drew loud boos and jeers when he was introduced to the crowd. Wearing a dark suit and a tie, Mr. Trump arrived at Nationals Park just before the first pitch of the Houston Astros-Washington Nationals matchup.

Hours earlier, he had announced that U.S. forces had assaulted the hiding place of Islamic State leader Abu Bakr al-Baghdadi, who was killed in the raid in northeast Syria. At the same time, a divisive impeachment inquiry into the president is underway in Congress.

Mr. Trump and first lady Melania Trump entered a lower-tier box to the left of home plate as the game was beginning. At that point, his presence hadn't yet been formally announced, but baseball fans in the section just below his suite turned to look toward the box as he arrived. Some waved at the president as he smiled and gave a thumbs-up.

President Donald Trump is introduced during the third inning of Game 5 of the baseball World Series between the Houston Astros and the Washington Nationals Sunday, Oct. 27, 2019, in Washington. Pablo Martinez Monsivais / AP

At the end of the third inning, the president stood and waved to the crowd, and ballpark video screens carried a salute to U.S. service members that drew cheers throughout the stadium. When the video on the Jumbotron cut to the president and his entourage — which included a number of GOP lawmakers — and the loudspeakers announced the Trumps, cheers abruptly turned into a torrent of boos and heckling from what sounded like a majority of the crowd. Chants of "Lock him up!" broke out in some sections, including one below where the president was sitting.

Get Breaking News Delivered to Your Inbox

Mr. Trump appeared unfazed and continued waving. Later, some fans behind home plate held a sign reading "VETERANS FOR IMPEACHMENT." Another banner appeared during the game: "IMPEACH TRUMP!"

The president remained at the game for seven innings before heading back to the White House. The Astros took a 3-2 series lead with a 7-1 victory in Game 5.

Until Sunday night, Mr. Trump hadn't attended a major league game as president even though the White House is a few miles northwest of Nationals Park. A dozen or so congressional lawmakers accompanied him, according to a list provided by the White House, including Senators Lindsey Graham of South Carolina and David Perdue of Georgia, and Representative Steve Scalise of Louisiana and House Minority Leader Kevin McCarthy.

A red banner reading "Impeach Trump!" appeared over right field during game 5 Sunday night in the World Series. CBS News - Arden Farhi

"I think everybody is excited," Nationals star pitcher Stephen Strasburg said before the game. "It's the president of the United States. So there's obviously beefed-up security. So usually the dogs that are sniffing in our clubhouse are these nice Labs that are super friendly. And today there was a German shepherd that I didn't really feel comfortable petting."

Nationals manager Dave Martinez said: "He's coming to the game. He's a fan. Hopefully he cheers for the Washington Nationals, and I hope he enjoys the game."

Mr. Trump's staff has long tried to shield him from events where he might be loudly booed or heckled, and he has rarely ventured into the neighborhoods of the heavily Democratic city. He won just over 4% of the vote in the District of Columbia in 2016.

Major League Baseball Commissioner Rob Manfred said he discussed with the president whether he'd like to throw out the ceremonial first pitch, but the president declined, citing the disruption that would cause fans getting to the ballpark.

Washington Nationals principal owner Mark Lerner told the Washington Post that Mr. Trump should be at the game, but he made clear that he did not invite the president to throw out the first pitch, saying there were many other candidates who should be considered before Mr. Trump.

Jose Andrés, a prominent local restaurant owner and humanitarian, threw out the first pitch to a roaring, sustained ovation. He has a history with the president, too, both in business and in politics.

Andrés has repeatedly opposed Mr. Trump's immigration policies and his administration's response to Hurricane Maria in Puerto Rico. Four years ago, he withdrew from plans to open a restaurant in the Trump International Hotel in Washington following Mr. Trump's controversial comments about Mexican immigrants during the presidential campaign. Legal action ensued and the dispute was settled in 2017.

—Arden Farhi contributed to this report.