Republicans are pushing back on the outcome of a tightly contested election in Western Pennsylvania, where results have shown Democrat Conor Lamb beat Republican Rick Saccone by just 627 votes.

The election in Pennsylvania's 18th District, a GOP stronghold that President Trump won by nearly 20 percentage points during the 2016 election, has set off alarm bells for Republicans as midterms near.

Lamb has declared victory multiple times, while Saccone has claimed the race is "far from over."

[Read the story: Trump: Democrat Conor Lamb won Pa. 18 special election because he's 'like Trump']

The GOP is mulling legal action and considering trying to get the votes recounted, according to the Associated Press.

Here's how the process of counting votes — and requesting a recount — works in Pennsylvania.

Election officials first review the votes 

As is standard procedure, county election officials will review the votes beginning 9 a.m. Friday. Essentially, they're making sure the number of votes cast lines up with their records.

This process could be completed by the end of Friday or extend into early next week.

Military and overseas ballots are still being accepted through next week

These ballots can be accepted until Tuesday, March 20; in other words, until a week since the election. On Wednesday, March 21, officials will review these ballots to make sure the number lines up correctly with their records. This process could be completed by the end of Wednesday.

As of a day after the election, the four counties in the Pittsburgh-area district reported they had about 375 uncounted provisional, military and overseas ballots.

To trigger a recount

According to Pennsylvania state law, an automatic recount is triggered if a candidate wins a statewide election by less than 0.5 percentage point. However, that law doesn't apply to elections in individual districts, such as District 18.

In this case, three voters in a precinct have to file petitions alleging that fraud or an error occurred. The county board of elections would then examine the vote totals produced by each voting machine, according to the Pittsburgh Post-Gazette. The newspaper also said that votes cast by paper must be tallied again by hand or by a different type of electronic machine than the one used in the first counting.