Presidential election recount efforts in Pennsylvania and Wisconsin came to an end on Monday, with both states certifying Donald J. Trump as the winner in contests that helped put him over the top in the Electoral College tally.

Mr. Trump’s victory in Wisconsin was reaffirmed after a statewide vote recount showed him defeating Hillary Clinton by more than 22,000 votes.

In Pennsylvania, a federal judge issued a stinging rejection of a Green Party-backed request to recount paper ballots in that state’s presidential election and scan some counties’ election systems for signs of hacking.

The Green Party candidate, Jill Stein, successfully requested and paid for the Wisconsin recount, but the courts blocked her attempts for similar statewide recounts in Pennsylvania and Michigan.