The charismatic Brazilian driver - back in racing less than a month after being acquitted of U.S. charges of tax evasion - took a big gamble, voiding a fast qualifying effort from earlier in the day and knocking Penske Racing teammate Ryan Briscoe off the pole.
"This place is magic," said Castroneves, a two-time Indy winner. "It's just amazing... We just had to keep working through the weather, working through the day. Ryan and I were really strong. When he went out there at the end, I was thinking I didn't really want to have to go out (again).
"Today was about finding the edge. The first attempt was a little easy. That means you're not going fast enough. We worked a little bit and made it a little bit tougher."
Asked if this was even more special because of the uncertainty he faced at the trial in Miami, he said: "Being here is already being special. Many times during the trial I was thinking about it. I was just wishing I would be here."
With wind gusts up to 25 mph making the Brickyard oval more treacherous than normal and each entry allowed up to three qualifying attempts, many of the teams were trying to outguess the gusts.
Dario Franchitti, the 2007 Indy winner, waited until after an early flurry of qualifiers in the windiest part of the day and wound up being good enough for third on the grid.
"That wind is horrible," said the Scot. "It was very, very challenging conditions. The four laps, it was very, very difficult to keep the balance."
Franchitti's effort bumped Castroneves to the outside of the front row and the Penske team quickly prepared Castroneves' car for his fast effort.
20-year-old Graham Rahal, the son of 1986 Indy winner Bobby Rahal, flirted with the front row, but wound up fourth, followed by Scott Dixon, Kanaan, Mario Moraes, Marco Andretti, Will Power, Danica Patrick and Alex Lloyd, who barely made it into the first-day lineup in the last five minutes, bumping Hideki Mutoh.
Mutoh, who qualified earlier, was bumped from the top 11 twice, while Raphael Matos, Ed Carpenter and Paul Tracy, making his first Indy appearance since losing in a controversial finish with Castroneves in 2003, were also bumped late in the session.
All of them will have another opportunity on Sunday when the next 11 spots in the lineup are filled. The other 11 positions will be filled next Saturday, with next Sunday reserved for drivers attempting to bump the slowest qualifiers out of the field.