The second-seeded Nadal looked far from his best at times, but he won on Centre Court in a match that finished under the roof after a rain delay during the fourth set.
"Yeah, not the best start honestly," Nadal said of Thursday's victory. "I finished playing well. The fourth set has been the level of tennis for me, important improvement. The rest of the things, I have room to improve."
Nadal is looking for a record-extending 23rd Grand Slam title, and third Wimbledon trophy.
In other men's matches, former French Open finalist Stefanos Tsitsipas, the fourth seed, set up a showdown with fellow hard-hitter Nick Kyrgios, advancing to the third round with a 6-2, 6-3, 7-5 victory over Jordan Thompson of Australia on No. 1 Court.
Tsitsipas broke Thompson in the final game to clinch the win on his third match point when the Australian sent a shot long.
It's the first time since 2018 that he is into the third round at Wimbledon, having lost in the first round last year and 2019. Tsitsipas, who lost last year's French Open final to Novak Djokovic, reached the fourth round in 2018 for his career-best result at the All England Club.
"It's going to be a challenging one on grass for sure,'' Tsitsipas said about facing Kyrgios. "He's a big opponent for this surface.''
Kyrgios beat 26th-seeded Filip Krajinovic 6-2, 6-3, 6-1 on No. 2 Court, reaching the third round with a performance that made sure his tennis was the only talking point this time by showing off an array of shot-making that included 50 winners, 24 aces and a couple of crowd-pleasing "tweeners.''
Kyrgios never faced a break point and looked fully focused throughout the match, without getting into any major arguments with the chair umpire or the crowd -- though he did berate one fan for coughing during the second set.
After his first-round win, the volatile Australian spit in the direction of a spectator he said had been hassling him, which resulted Thursday in a $10,000 fine for unsportsmanlike conduct.
Said Kyrgios of the win Thursday: "I just wanted to remind everyone that I'm pretty good.''
Nakashima, who is ranked 56th in the world and advanced to the same stage at this year's French Open, will next face Daniel Elahi Galan. The Colombian advanced to the third round when Roberto Bautista Agut withdrew from the tournament after testing positive for COVID-19.
Britain's Liam Broady upset No. 12 Diego Schwartzman, while Taylor Fritz (11), Botic Van De Zandschulp (21), Lorenzo Sonego (27) and Jenson Brooksby (29) were among the seeded men's players to advance.
All in all, it's been quite a productive -- and rare -- start to Wimbledon for Nakashima, Fritz, Brooksby and other American men: There will be eight of them in the third round, accounting for a quarter of the 32 players left in the field, the most for the country at the grass-court Grand Slam tournament since 1995. It's also the most at any major since the 1996 US Open.
"We're moving in the right direction. Obviously the goal isn't the third round. The goal is much farther than that,'' said Martin Blackman, the general manager of USTA Player Development. "But when you get numbers like this, it's an indicator of a process that's working. So I think that's what's so encouraging. All the guys that are in the third round want to go much farther; I don't think any of them are satisfied.''
In 2013, zero men from the United States reached Wimbledon's third round -- something that hadn't happened since 1912, when no Americans entered the event.
"It's great to see everyone doing well, going deep in these tournaments,'' said Nakashima, a 20-year-old Californian.
The Associated Press contributed to this report.