She was running close to or leading Sen. Barack Obama in the crucial Philadelphia suburbs and was crushing him in southwestern Pennsylvania and the Scranton region.
"Some people counted me out and said to drop out, but the American people don't quit, and they deserve a president who doesn't quit either," Clinton told cheering supporters last night at the Park Hyatt Philadelphia at the Bellevue. "Because of you, the tide is turning."
With the support of Gov. Rendell, Mayor Nutter and much of the Democratic establishment, Clinton had been expected to carry the state, but the better-funded Obama was able to unleash an avalanche of television commercials and shave her lead in opinion polls.
Despite Clinton's win, Obama remains the front-runner for the nomination, with a significant overall delegate lead and a huge financial advantage. She also has few primaries left in which to overtake him.
Still, Clinton's big margins among white working-class voters seemed likely to add fuel to her argument that Obama cannot win the big industrial swing states in the fall against Republican John McCain.
After spending the afternoon in Philadelphia, Obama flew ahead to a rally with rocker John Mellencamp in Indiana, site of one of the next round of primaries May 6. He briefly acknowledged the Pennsylvania results in remarks that focused on Indiana and McCain.
"There are a lot of folks who didn't think we could make this a race when we started," Obama said. "Now, six weeks later, we closed the gap. We rallied people of every age and race and class. . . . We registered a record number of voters, and it is those voters who will lead our party to victory in November."
Voters swarmed the polls, given the chance to have a meaningful say in a presidential nomination for the first time in years.
Commonwealth Secretary Pedro A. Cortes described the turnout as "phenomenal." He said it might reach 50 percent statewide, perhaps eclipsing that of the 1980 primary, when President Jimmy Carter was challenged by Sen. Edward M. Kennedy (D., Mass.) for the nomination.
Hop-scotching the state
The same demographic split prevailed in most of the other contests between Obama and Clinton.
With no other contests on the schedule, the candidates hop-scotched across Pennsylvania for nearly seven weeks, spending $20 million on TV advertising - a bombardment that, for example, featured 228 spots a day in the Harrisburg media market. Obama, his campaign flush with cash, was able to outspend Clinton by a ratio of about 3-1 on the air.
A tough turn
"Who do you think has what it takes?" asked the ad.
Obama has struggled in some states to win over white working-class voters, older voters and Catholics, key parts of the coalition that strategists say a Democrat needs to carry big industrial swing states.
For his part, Obama said that anything less than a blowout win here for Clinton would do little to help her overcome his delegate lead because delegates are awarded proportionally.
Polls showed that Clinton always had the advantage among women, older voters, Catholics, union households, and white voters with high school educations making less than $35,000. Obama was leading among younger voters, African Americans, Democrats with incomes over $75,000, and liberals.
The state seemed demographically tailor-made for Clinton, with higher percentages than the nation as a whole of voter groups that have favored her in past races. Obama was counting on Philadelphia and its suburbs to overcome expected Clinton support elsewhere.
Clinton's campaign had been on the verge of elimination after 11 losses last month before she won popular-vote victories in Ohio and Texas based on her advantage with the working class.
As Obama drew close in Pennsylvania, he hit a rocky patch that analysts said halted his momentum.
There was the disclosure of remarks he made at a fund-raiser, characterizing small-town Pennsylvanians as "bitter" people who cling to guns religion and "fear of people not like them" because of their economic frustrations.
In a televised debate last week, Obama was thrown on the defensive about everything from inflammatory comments by his former pastor to his friendship with a member of the radical Weather Underground, to why he rarely wears an American flag pin in his lapel.
Obama had appeared to weather the storm over the pastor, the Rev. Jeremiah A. Wright Jr., giving a well-received Philadelphia speech on race relations March 19, in which he condemned Wright's incendiary sermons.
For her part, Clinton was caught mischaracterizing her landing under sniper fire in Bosnia on a 1996 visit, a story she was using to establish her foreign-policy bona fides.
The sniper incident and "bittergate" might be examples of the candidates showing the wear and tear from the extended campaign. Clinton began the campaign with doubts about her trustworthiness, but her negative ratings have risen sharply in the last few months.
About a quarter of the voters yesterday told exit pollsters that they made their decision within the last week.
Vashti West, a Philadelphia school teacher, was torn until she entered the voting booth at the City Health Center at Broad and Lombard Streets.
"I didn't want another eight years of Clintons," West said. "This is America. Give someone else a chance. They are not the queen and king of England. . . . It's been kind of fun to see her work for it."
That inspired Emily Kramer-Golinkoff, 23, a researcher. "Hillary has character," she said.
John Drees, 65, a retired from the Temple medical school faculty, said he was fed up with the "obscene" national debt, worrying about its effect on his grandchildren and beyond.
"I think Clinton is more electable," he said.
At stake in Pennsylvania were 158 delegates to the Denver convention, the largest prize left.