President Obama attends a "Get Out The Vote" rally for the Lt. Governor Anthony Brown, and County Executive Ken Ulman team at Wise High School in Upper Marlboro, Md. on October 19, 2014. (Jonathan Newton/The Washington Post)

President Obama stood before thousands of Marylanders in a high school gym in Prince George’s County on Sunday and urged them to vote for Democrats who fight for the working class — such as gubernatorial candidate Anthony G. Brown.

The president told the largely African American, and wildly enthusiastic, crowd that Republicans want voters to become so cynical that they don’t vote.

“If you want good policies to continue in Maryland, you’ve got to vote for them,” Obama said, and then listed priorities such as a higher minimum wage and making college more affordable.

“On every one of these issues, there is a clear choice,” he said. “On every one of these issues, Anthony Brown is on your side.”

Although Democrats outnumber Republicans more than 2 to 1 in Maryland, Brown has struggled to keep a comfortable lead over his Republican opponent, businessman Larry Hogan. Part of the reason is that Brown hasn’t locked up the support of African Americans, who heavily favored Obama in 2012, according to a Washington Post-University of Maryland poll released this month.

In that poll, 77 percent of likely African American voters supported Brown. In 2012, Obama won support from 97 percent of black voters, according to an exit poll.

Although Obama has seen his popularity fade in many parts of the county, he was welcomed with raucous applause at Dr. Henry A. Wise Jr. High School in Upper Marlboro. At times, the crowd punctuated each of his sentences with cheers. It also defended him with boos when a heckler challenged Obama on immigration.

It was a level of enthusiasm that Brown has yet to see as he campaigns to become the state’s first African American governor and thenation’s third to be popularly elected.Some in the crowd said they waited in line for hours to see Obama, not Brown.

“Since the president is behind him, I’ll be behind him,” said Heather Conyers, 24, of Upper Marlboro, who lined up outside the high school — located next door to Barack Obama Elementary School — at noon, two hours before the doors opened and five hours before the president took the stage.

As thousands of supporters waited in the gym, Maryland lawmakers urged them to vote early, starting Thursday.

Rep. Steny H. Hoyer (D-Md.) spoke about civil rights activists who were beaten and killed as they fought for the right to vote. That fight continues as some legislators try to make it harder to vote, he said.

“They know what you know and I know: If we show up, we win,” Hoyer said, later leading the crowd in a chant of “Vote! Vote! Vote!”

Brown continued that line of messaging.

“We don’t have to revisit the struggles and the suffering of the 1950s and the ’60s and generations of history in this country to exercise that most important and fundamental right to vote,” Brown said.

Hogan spent Sunday afternoon in Southern Maryland at the annual St. Mary’s County Oyster Festival. In coming days, he will welcome several luminaries from his own party. Tom Ridge, a former Pennsylvania governor and U.S. secretary of homeland security, is scheduled to attend a reception Monday night. On Tuesday, New Jersey Gov. Chris Christie, chairman of the Republican Governors Association and a potential 2016 presidential candidate, will support Hogan at a fundraiser in Potomac.

Hogan said Obama’s appearance is evidence that Brown’s campaign “is getting desperate and pulling out all the stops to try to stop our bipartisan grassroots upset.”

Obama campaigned for Gov. Martin O’Malley and Brown in Prince George’s County in 2010, when the two ran for reelection. Brown and Obama were classmates at Harvard Law School in the late 1980s and early 1990s. But ahead of the 2008 presidential election, Brown endorsed Hillary Rodham Clinton over Obama. Before the Democratic primary this spring, the campaign of Maryland Attorney General Douglas F. Gansler (D) released a radio ad criticizing Brown for having “worked to defeat Barack Obama when he first ran for president.”

The Clintons have been close allies of O’Malley and Brown, even as O’Malley and Clinton consider running for president in 2016. Former president Bill Clinton has attended two fundraisers for Brown this year that collectively raised more than $2.2 million.

Hogan, who grew up in Prince George’s, has said he is not ceding the African American vote.

During a forum hosted by Alpha Phi Alpha fraternity at Bowie State in September, Hogan told a predominantly black crowd that his message of cutting taxes and creating jobs should resonate everywhere, including in African American neighborhoods. Brown did not attend.

“Don’t let anyone tell you that you have to vote for or against someone just because of their party affiliation or the color of their skin,” Hogan said at the event.

As Obama spoke Sunday, he received rousing applause for mentioning healthcare reform and equal pay for women, among other issues. He wrapped up by saying: “Anthony Brown devoted his life to fighting for you. You now need to fight for him.”

Afterward, Obama and his security entourage worked his way along a line of supporters. Raised cameras followed his every move. Brown followed a couple steps behind, trailed by his campaign manager.

John Wagner contributed to this report.