BOSTON – With poll numbers showing a tightening Massachusetts Senate race, President Obama made a stop in the Bay State Wednesday to raise money and rally the state’s powerful Democratic base for Rep. Edward Markey ahead of a June 25 special election.

“You can’t just turn out in a presidential election, you’ve got to turn out in this election,” Obama told an enthusiastic crowd of thousands at the Reggie Lewis Track and Athletic Center in a heavily Democratic neighborhood. “I need you knocking on some doors right now, in June.”

Democrats are suddenly nervous about Markey’s chances against Republican Gabriel Gomez and they are scrambling to bolster their get-out-the-vote effort.

Early polls showed Markey with a comfortable lead of about 12 percentage points, but two polls released this week from WBUR/MassINC and Suffolk University each showed Markey's lead shrinking to 7 points.

Gomez, a businessman and former Navy Seal, is hoping to replicate former Sen. Scott Brown’s grassroots-based GOP victory in the 2010 Senate race here. He said on Wednesday that Obama’s visit signals that Democrats know he can win.

“It signals Congressman Markey is extremely scared,” Gomez said after attending a technology roundtable in Waltham Wednesday morning.

The move by the Democrats to hold the rally in Roxbury signals the party’s strategy of getting their most loyal voters to the polls rather than attempting to win over the state’s large population of independent voters.

“I am going to be working 24 hours a day to get out the vote,” Markey told the Roxbury crowd.

Markey, 66, won his congressional seat in 1976 and has since built one of the most liberal voting records in Congress. Gomez, 47, is a moderate Republican who voted for Obama 2008.

Democrats fear a repeat of January 2010, when Democratic Senate candidate Martha Coakley fumbled a double-digit lead against Brown just two weeks before Election Day. Brown beat Coakley by 5 percentage points in part by winning over independent voters.

Obama dropped in for a rally in that race, but it was just days before the election and too late to do much good for Coakley.

Some pollsters believe the Markey-Gomez race is tightening because voter are becoming disenchanted with the Obama administration, which has been dealing with a series of scandals involving the targeting of conservative groups by the Internal Revenue Service and snooping by the National Security Administration and Justice Department.

But Obama remains enormously popular in Massachusetts, a blue state that picked him over Republican Mitt Romney, the state’s former governor, 61 percent to 38 percent.

Many of the people who attended Wednesday’s rally were clearly more eager to see the president than Markey.

“That’s why I’m here,” said Marguerite MacDonald, of Tewksbury, who was waiting in a crowd to get a glimpse of Obama inside the athletic center. “I think Obama’s wonderful. He has the most difficult job in the world and he is doing his best.”

At the rally, Markey, who has been criticized for spending most of his time in the affluent D.C. suburb of Chevy Chase, Md., sought to appeal to the working class voters in the Boston area.

“This election is about making sure the wealthy pay their fair share,” Markey told the crowd. He called for “a green energy revolution,” and for making the National Rifle Association acronym stand for “Not Relevant Anymore.”

Before the event, Markey and Obama attended a fundraiser in downtown Boston, then stopped by a sandwich shop in the working-class South End neighborhood.