Sato, of Andretti Autosport, beat Brazilian runner-up Helio Castroneves, with Britain's Ed Jones finishing third.
Castroneves was chasing his fourth Indy 500, a feat that he would have been just the fourth man ever to achieve.
He overtook British former F1 driver for the lead with five laps to go in a move that looked to be decisive.
However, Sato followed him through and got past with less than two laps to go.
Castroneves had just one more chance to overtake and claim that victory again but the Japanese racer was aggressive in his defence and clung on for a famous victory.
Sato said: “Unbelievable feeling. It was a tough tough race. Hopefully the crowd enjoyed it. I can’t thank enough for everyone’s support.”
Takuma Sato produced a stunning race to win the Indy 500
Much of the pre-race focus had been on Formula One driver Fernando Alonso – who had swapped the Monaco Grand Prix for Indy 500.
But his efforts came to and end in the final stages as he suffered engine failure.
"I felt the noise and the engine friction so I backed off," he said.
"It's a shame because I felt we deserved to finish and experience the last lap – who knows where we could have finished.
"The whole thing has been a nice experience. The racing was fun and I am glad to been here with the best racers in the business.
"It's early (to decide if he comes back) but I feel competitive and if I come back I will feel like I know what to expect so will use that next time.
Get Quotes on Home Insurance
"Thanks to Indycar because this has been one of the best experiences of my career."
Helio Castroneves, who finished second added: "My little girl congratulating me is what makes me smile. I want to thank the fans. You guys saw, it was a little too hard for me today. Congrats to Takuma Sato – he bumped me a couple of times, I was like "Wow this car is really unbreakable!"
"I really tried hard! I think I bent the throttle pedal, I was pushing that hard!
"When I saw the 77 car bounce back, I thought something was going to happen. When I saw the car flipping, I don't know how I held on, I think it was the guy upstairs holding on for me.
"I want to thank my entire team. We fight together but it wasn't my day."