Hamilton is fighting to stay in contention for the title after a season of disappointing mechanical failures.
He trails Rosberg by 33 points and with only four races left including Sunday's battle in Austin, Texas, the British racer's hopes are dependent on the German slipping up.
Three-time champion Hamilton finished just two tenths of a second in front of Rosberg, punching the air as he crossed the line.
Red Bull racers Daniel Ricciardo and Max Verstappen occupy the second row of the grid with the Ferrari racers Kimi Raikkonen and Sebastian Vettel behind them in fifth and sixth places.
Nico Hulkenberg, Valtteri Bottas, Felipe Massa and Carlos Sainz make up the rest of the top 10 in qualifying.
"I feel amazing," Hamilton told reporters after the qualifying session.
"This is my first pole here, and it has been many years of trying. So, I am very happy today.
"I want to say a big thank you to the crowd. I could hear them cheering. It was much appreciated, and I hope tomorrow we can deliver another great race."
Rosberg added: "Lewis was just quicker in sector one which was pretty simple. It was a good lap."
It will be a nerve-wracking race for Hamilton's father Anthony who recently told CNN Sport
that the agonies of watching his son race haven't changed over the last 10 years.
"It's the same nerves, the heart palpitations when the race gets going," he said.
Lewis Hamilton's return to a pole position may help calm his father's emotions after the British racing star appeared to lose focus following an engine failure.
At the last race in Japan he amused himself on social media during an official conference, leading to criticism that he showed a lack of respect.
"Lewis is still the same person he always was but he lives in the bubble of motorsport," said his father.
"The human side of Lewis is what you saw recently. 'I know you guys have a job to do but I'm not really enjoying it. Why don't we try this for a change?' I think Lewis had a good point."