After beginning the day one stroke behind Lewis, Ko birdied three of her final four holes on the front nine on the way to a 3-under 69 and 12-under 276 total at Lake Merced.
Ko takes home $US270,000, ($NZ315,000) celebrating on the 18th green three days after celebrating her 17th birthday at the first tee box with a "Happy Birthday'' song from the gallery.
Ko will move up two spots to No. 2 in the next world ranking.
Her first title as a professional came at the Swinging Skirts World Ladies Masters in Thailand last December.
"It was just intense the whole day," Ko said in a TV interview after the win.
"I made a couple of bogeys on the front nine and I tried to recover with some birdies. I still finished my front nine one-under par which I was surprised about that.
"I had a two shot lead and then Stacy made a birdie and Jenny made a birdie. The 18th hole I knew how loud the claps were so I knew I had to hit it close and give myself a birdie opportunity."
Ko's father was to watch the victory, the first time he's seen his daughter win as a pro.
"It makes it really special," Ko said. "Last year at the Swinging Skirts my sister and my mum were there and now it's my dad and my mum so hopefully one day the whole family will be here."
- With AP