Joshua Shapiro woke up at 5:30 a.m. Friday, grabbed his iPhone and from his bed started answering e-mails about power outages in Sandy-slammed Montgomery County. He had 800,000 people and public facilities to worry about as the top elected executive of this county in Philadelphia’s suburbs, and he also had polling places to get back in operation as the top Democratic leader here.

His Democrats were rattled. They have been smacked around statewide since conservatives set up a permanent tea party in the capital, Harrisburg, but they have persisted in believing that the state was proudly and permanently blue in presidential elections. And yet, Pennsylvania is suddenly being treated like a battleground.

Polls have tightened, and President Obama’s lead is now just slightly larger than the statistical margin of error. Some $10 million in ads for Republican challenger Mitt Romney flooded in last week, large Romney-Ryan yard signs have sprouted on the spacious lawns of these affluent suburbs, and Romney swooped in Sunday for a rally that drew 30,000 to a farm in neighboring Bucks County.

If the GOP nominee hopes to be the first in nearly a quarter-century to pick off Pennsylvania’s 20 electoral votes, he’ll have to eat into the fat margin that Montgomery County delivered to Democrats in 2008. The Obama campaign is concerned enough about the state that it has reserved ad time during the “Monday Night Football” game in which the beloved Philadelphia Eagles are playing, and former president Bill Clinton is packing in four rallies Monday.

The gritty hand-to-hand combat to turn out voters, always intense on the weekend before Election Day, has taken on a frenzied quality this year in a state with no early voting and a requirement that a voter must really be absent to get an absentee ballot.

Explore the 2012 electoral map and view historical results and demographics

The hurricane messed up the careful calibrations of the vaunted Obama get-out-the-vote operation. About 25 polling places, most in the eastern part of the state, remained without electricity late Sunday. Some 81,000 customers were in their seventh day with no power. Each day brings another legal skirmish over access to the polls in a state whose Republican-controlled legislature enacted one of the most restrictive voter-identification laws in the country.

“Having Romney come here, does it mean we are at risk?” asked Allyson Schwartz, a Democratic congresswoman seeking her fifth term. She was one of the candidates Shapiro had led into the drab basement of a condo building here, the first event in a long weekend of energizing an electorate distracted by toppled trees, lost power and a deferred Halloween.

“I’m nervous,” said Shirley Curry, a longtime local Democratic leader. “Did you hear that new Romney radio ad? It’s good.”

People deconstructed, nervously, what former governor and Democratic National Committee head Edward G. Rendell said recently about the possibility of a “startling upset” in the state: Was he acknowledging Romney’s appeal? Or was that a head fake, a way to get people fired up?

Turnout at this point is everything, Schwartz told the 60 or so people, mostly retirees, when she took the mike. “With some people being stressed out, we worry about that. You’re worried about your freezer. You’re worried about your children and your house.”

Every four years for the past 20, Pennsylvania has looked tempting at the last minute to Republicans. It has a bedrock of rural conservatism that may be harder than ever in its center, even as Pittsburgh and the eastern counties have softened their blue hue to violet. The last Republican presidential candidate to win the Keystone State was George H.W. Bush in 1988. His son George W. Bush came to the same farm where Romney appeared, on the same Sunday before the 2004 election, to declare he would take the state — and lost by more than 140,000 votes.

White House senior adviser David Plouffe on television Sunday morning said it was a “desperate ploy” to have Romney travel to a state “he’s not going to win.”

But where Democrats see desperation, Republicans see opportunity.

Romney “relates better to those folks in the collar counties than any other recent GOP candidate,” said Billy Pitman, the Romney campaign communications director for Pennsylvania. “The day after they saw him unfiltered in that first debate, we had a couple hundred people volunteer across the state.”

The Republicans took note that about 85,000 Democrats who voted in the state’s primary didn’t cast a ballot for Obama, an undervote that they theorize shows a lack of confidence in the president’s leadership that they can build upon, particularly in the coal counties bordering Ohio, Pitman says.

Shapiro, who never voices anything but confidence, doesn’t buy it.

“I really don’t think this race has changed that much,” he said. Citing Romney’s attempt to court moderates and independents, he said: “He has extreme positions on choice and on gay marriage, and there is vast regional distaste for that here, including with moderate Republican women. I don’t see him catching fire in the suburbs, and if you don't catch fire here” in the four counties ringing Philadelphia, with their third of the total state vote, “you don’t win.”

Obama won Montgomery County by 20 percentage points — and nearly 87,000 votes — in 2008. He won Pennsylvania by 10 points, and the votes that piled up just in Montgomery, Delaware and Philadelphia counties compensated for his losses elsewhere in the state.

At 39, Shapiro is the first Democrat in 140 years to chair the three-person board of commissioners that runs the state’s third most populous county.

That is why he brought candidates including Schwartz, Sen. Robert P. Casey Jr. and state candidates for attorney general and auditor general to the condo building’s basement and later led them into the shops of nearby Keswick Village.

On Saturday, he made two appearances with second lady Jill Biden to pump up voters and continued to campaign with Casey, who has seen slippage in his reelection lead over Republican Tom Smith, a coal-mining executive who is a tea party favorite. On Sunday, there were three more events, including a rally at the University of Pennsylvania that drew a crowd of 25,000.

At the Keswick Tavern on Friday, where Halloween lights were still strung and the sandbags still piled up outside, and where grateful Hurricane Sandy refugees had availed themselves of the 24 beer labels on tap through a hard week, the retail politicking paused for a toast.

Tasting glasses of ale were poured. The politicians lifted theirs into the air.

“To Election Day!” said Leslie Richards, vice chairman of the board of commissioners. “And to having power at all the polling places.”