Ever since Vice President Kamala Harris entered the presidential campaign three weeks ago, polls and campaign finance data have shown how the race has changed. She has come from behind to build a small lead over former President Donald J. Trump in national polls and in several swing states, and she raised far more money than he did last month.

Now, new voter registration data in two swing states adds to the evidence that Ms. Harris’s candidacy has energized potential Democratic voters.

For nearly the entire year, more people had been registering as Republicans than as Democrats when signing up to vote in Pennsylvania and North Carolina, two battleground states that use party registration and that release this data regularly.

There was a big spike in G.O.P. registrations in both states the week of July 14, during the Republican National Convention, which came days after Mr. Trump survived an assassination attempt. In Pennsylvania, more voters registered as Republicans than in any single week since 2020.

But the following Sunday, President Biden dropped out of the race and endorsed Ms. Harris. In the week that followed, Democratic registrations surged. For the first time this year, weekly Democratic registrations outnumbered Republican registrations in North Carolina. In Pennsylvania, it was the largest Democratic margin in new registrations since late 2023.