Williams, the 2000 and '01 champion at Flushing Meadows, finished with 60 unforced errors. The match lasted 2 hours, 45 minutes.
She finished the year with only two victories at the Grand Slam events -- one at the French Open and another at Flushing Meadows.
Last year, Williams departed the U.S. Open before her second-round match, suffering with Sjogren's syndrome, an illness that causes joint pain and fatigue.
This time, buoyed by chants of "Let's go, Venus!" in a mostly empty Arthur Ashe Stadium -- perhaps spectators figured in the second set that Kerber was on her way to a swift victory -- Williams found the resolve and energy to put aside her 16 double faults and 60 total unforced errors and help produce as entertaining a contest as the arena has hosted this week.
"I know this is not proper tennis etiquette, but this is the first time I've ever played here that the crowd has been behind me like that. Today I felt American, you know, for the first time at the U.S. Open," Williams said. "So I've waited my whole career to have this moment and here it is."
At changeovers in the third set, trying to concentrate on her coach's game plan, Kerber draped a white towel over her head, looking a bit like a little kid dressing as a ghost for Halloween. She would lift the towel's edge every so often so she could tuck a water bottle underneath and take a sip.
"Venus is such a great player. ... Everybody was against me," Kerber said, referring to the crowd, "but it doesn't matter."
Williams overcame six double-faults and 24 unforced errors. The fourth-seeded American had 32 winners to five for Martinez Sanchez.
In the 2009 French Open third round, Williams hit a ball she was sure went off Martinez Sanchez's arm, then said the Spaniard cheated by not acknowledging it.
Martinez Sanchez has been ranked as high as 19th but is at No. 108 after struggling with a right thigh injury this year.
Williams next faces 42nd-ranked Russian Ekaterina Makarova.
A week before the start of the U.S. Open, Ana Ivanovic couldn't walk without pain in her right foot.
"That's when I started to panic a little bit," she said Thursday.
Two matches into the tournament, the 2008 French Open champion is feeling healthy -- and relaxed.
The 12th-seeded Ivanovic and another Serbian former top-ranked player, Jelena Jankovic, have quietly reached the third round at Flushing Meadows. Each has dropped just nine games through a pair of straight-set wins.
Ivanovic beat 51st-ranked Sofia Arvidsson of Sweden 6-2, 6-2 on Thursday.
Asked if the torn tendon is fully healed, Ivanovic laughed and said, "I still have a handful of pills every morning."
But Ivanovic knows that being the favorite guarantees nothing. In 2008, coming off that title at Roland Garros and at No. 1 in the world, she was stunned by 188th-ranked Julie Coin in the second round here, bothered by a thumb injury. The top-seeded woman had never lost that early in the tournament since the Open era began in 1968.
Ivanovic has been trying to regain her health and her confidence ever since. She has yet to make it back to even a quarterfinal of a Grand Slam event.
"I'm really motivated. I want to get back to the top and back in contention to win Grand Slams again," Ivanovic said. "It's been a long process of getting my mind there and my body and game and everything together. Still, it's going to be a lot of hard work and long process, but I'm starting to enjoy it as well.
"I know if it doesn't happen this week, it's coming."
It's a similar story for Jankovic, who defeated 115th-ranked Lara Arruabarrena-Vecino of Spain 6-4, 6-2 on Thursday. Both women reached No. 1 in the world in 2008, a breakthrough year for Serbian tennis when Ivanovic won the French, countryman Novak Djokovic took the Australian Open, and Jankovic reached the final at Flushing Meadows.
While Djokovic has since won four more Grand Slam titles, Jankovic lost in the first round at Wimbledon this year.
She's seeded 30th this week -- though, as she noted with a laugh, her ranking is now up to No. 27.
Information from The Associated Press was used in this report.