Giants players celebrate their victory away at Philadelphia
San Francisco Giants ended Philadelphia Phillies' hopes of a third straight National League championship as they beat them to reach the World Series.
The Giants will take on World Series debutants Texas Rangers, who beat champions New York Yankees 4-2 to win the American League championship.
Juan Uribe's eighth-inning home run proved decisive as the Giants won 3-2 to take the best-of-seven series 4-2.
It will be the Giants' first World Series appearance since 2002.
The last time they won the title was in 1954, as the New York Giants.
Texas, who began as a franchise in 1961 as the Washington Senators, have never reached the Fall Classic before.
"That was epic. What a battle. I hope the fans back home are going absolutely ballistic," said the Giants' Brian Wilson after their win.
Phillies manager Charlie Manuel was left to rue missed opportunities.
"We had chances, we just couldn't cash in on them, we couldn't get the big hit," he said.
The Rangers sealed their place in the end-of-season series with a 6-1 win over the Yankees on Friday, to clinch a 4-2 championship series victory.
Vladimir Guerrero drove in three runs and Nelson Cruz hit a home run as Texas sealed an emphatic victory in Dallas.
The Rangers dominated the series against the 2009 champions
Texas's rookie closer Neftali Feliz struck out former Ranger Alex Rodriguez for the final out, triggering wild celebrations at Rangers Ballpark.
"This group is here because they don't know how to fail," said outfielder Josh Hamilton, who was named Most Valuable Player of the series.
"The chemistry of this team is like something I've never known anywhere."
The defeat ended the Yankees' quest for a 28th World Series title.
"They beat us [fairly]," said New York manager Joe Girardi. "They out-hit us, they out-pitched us, out-played us."
The best-of-seven World Series starts in San Francisco on Wednesday 27 October, with the final game - if needed - also taking place in California on Thursday 4 November.