PHILADELPHIA (CBS) – Pennsylvania voters are poised to play a crucial and perhaps decisive role in choosing the next president as Donald Trump and Joe Biden headline a statewide election in which millions of ballots have already been cast. Polls opened Tuesday against the backdrop of a pandemic, a police shooting and civil unrest in Philadelphia, and the potential for a drawn-out legal fight over late-arriving mail-in ballots.

Election officials cautioned the winner might not be known for days as counties begin tabulating more than 2.4 million votes that arrived by mail.

Photos posted on social media showed long lines forming at many polling places.

Voters also are deciding races for Congress, the General Assembly and a trio of statewide offices – attorney general, auditor general and treasurer.

Trump, the Republican incumbent who scored a surprise victory in Pennsylvania four years ago, and Biden, the Democratic challenger and native son, have frequently visited the battleground state, each seeing victory here as crucial to their chances of winning the White House. Biden planned a campaign stop Tuesday in Scranton, where he spent part of his childhood, before heading to Philadelphia.

Trump signs sprouted in lawns throughout small-town and rural Pennsylvania – the state’s Republican-dominated “T” – while Biden’s hopes hinged on getting huge margins in the Democratic bastions of Pittsburgh and Philadelphia, as well as in the heavily populated, trending-blue Philadelphia suburbs. Polls leading up to Election Day showed a competitive race.

Trump has tried to sow doubt about the fairness of the election, saying the only way Democrats can win Pennsylvania is to cheat. Without evidence, he said late Monday that a court decision to allow Pennsylvania to count mailed ballots received up to three days after the election will allow “rampant and unchecked cheating” and will induce street violence.

State election officials have pushed back strongly, pledging a safe and secure election. Gov. Tom Wolf, a Democrat, promised accurate results, “even if that takes a little longer than normal.” Democrats accused Trump of waging a campaign of voter intimidation and suppression.

The county-by-county tabulation is expected to last for several days because of a year-old state law that greatly expanded mail-in voting. The state Supreme Court, citing Postal Service delays, the huge number of people voting by mail because of COVID-19 and the strain on county boards of election, ordered counties to count mail-in ballots received up to three days after the vote, so long as they are mailed by Election Day.

The status of mailed ballots arriving after polls close at 8 p.m. has the potential to become significant if the nationwide result hinges on the outcome of Pennsylvania’s vote, and if the ballots are potentially decisive. Republicans have asked the U.S. Supreme Court to prevent any late-arriving ballots from being counted, citing state election law. The great majority of mail-in ballots have been cast by Democrats, according to state data.

Amid the legal wrangling, civil unrest in Philadelphia became a political issue in the closing days of the campaign.

The fatal police shooting last week of Walter Wallace Jr., a Black man holding a knife, sparked violent clashes between police and protesters, widespread vandalism and the ransacking of stores. Trump sought to use the unrest to push a law-and-order theme and castigate big-city Democrats as leading a “war against police.” Biden, meanwhile, expressed sympathy for Wallace’s family and called for “real police reform” while condemning the violence and looting.

Trump won Pennsylvania by less than 1 percentage point in 2016, eking out a surprise victory over Democrat Hillary Clinton to become the first Republican presidential candidate since 1988 to take the state. No Democrat has lost Pennsylvania but won the White House since Harry Truman in 1948.

The candidates visited the state at least once a week since the beginning of September – including a flurry of last-minute campaigning over the weekend and on Monday – and more money was spent on political advertising in Pennsylvania this campaign than in any state but Florida, according to the political ad tracking firm Kantar/CMAG.

Though the presidential race sucked up most of the attention, there were other important races on the ballot.

All of Pennsylvania’s 18 congressional seats – currently occupied by nine Democrats and nine Republicans – are up for grabs.

A pair of Democratic incumbents, Attorney General Josh Shapiro and Treasurer Joe Torsella, are seeking reelection, while Pennsylvania will pick a new auditor general to replace term-limited Democrat Eugene DePasquale.

Control of the state House is also at stake, with Democrats needing nine seats to seize the majority from Republicans after a decade out of power. Democrats also have a gap to make up in the state Senate.

Copyright 2020 The Associated Press.

MORE ON CBS PHILLY:

President Trump Threatens Legal Action To Stop Counting Of Pennsylvania Ballots Arriving After Election Day

‘I Got A Jail Cell For You’: DA Larry Krasner Issues Warning ‘If You Are Planning In Philadelphia To Steal Our Votes’

2 Civilians Rescue 26-Year-Old Woman From Attempted Abduction In Center City, Police Say