The 39-year-old Mexican, who had lost twice and drawn once in their three previous meetings, sent Pacquiao crashing to the canvas with a stinging right hand with one second left in a bruising round at the MGM Grand Garden Arena.
The Filipino southpaw fell face first and lay motionless for a couple of minutes before being helped to his corner where he sat on a stool as his gloves were removed.
Pacquiao, who has won world titles in an unprecedented eight weight divisions, was later taken to the nearby University Medical Center hospital for a precautionary CAT scan.
“I knew Manny could knock me out at any time. I threw a perfect punch,” said four-division world champion Marquez, who had his nose broken by Pacquiao.
“We always worked on that (counter punch),” added the Mexican after improving his record to 55-6-1 with 40 knockouts.
“We knew he was going to come out aggressive so we had a fight plan that was more technical. We were able to capitalize on it. I put this fight as one of my greatest victories.”
Back in the ring for the first time since beating Ukrainian Sergey Fedchenko on an unanimous decision to win the WBO light welterweight title in April, counter-punching specialist Marquez was confident he could out-box Pacquiao.
“I felt he was coming to knock me out the last three rounds and I knew he was going to be wide open,” the Mexican said. “We had to use our technique and skill and we didn’t allow Manny to connect as he had done before.”
Pacquiao was knocked down in the third round but sent Marquez to the floor in the fifth and looked to be getting the better of the scheduled 12-round fight until he missed with a right and was stunned by a thunderous counter-punch.
“He’s not an easy opponent,” the Filipino said after slipping to 54-5-2 with 38 knockouts. “I was just starting to feel confident and then I got careless. I did my best.
“I thought I was getting him in the last couple of rounds but I got hit by a strong punch. I didn’t expect that punch,” said Pacquiao, who was given a pep talk by defeated U.S. Republican presidential candidate Mitt Romney before the bout.
Asked if he would like to fight Marquez for a fifth time, Pacquiao replied: “Yes, why not? It’s a good fight. If you give us a chance, we’ll fight again.”
It was the second defeat in a row for the Filipino, who lost on a hotly disputed split decision to American Timothy Bradley in June.
Watched by a sell-out crowd of 16,000 that included former heavyweight champion Mike Tyson and basketball great Magic Johnson, the two fighters made an energetic start with Pacquiao establishing a slight advantage through his lightning left jabs.
The Filipino caught Marquez on the chin with a crunching left in the second round and dominated early in the third with his nimble footwork before he was stunningly sent to the canvas by a Marquez right hook.
It was the first time Pacquiao had been knocked down by Marquez in 39 rounds contested by the fighters.
The Filipino responded with a flurry of combinations in the fourth round, then dropped Marquez with a straight left in the fifth and the Mexican ended that round with a bloodied nose after being pinned against the ropes.
Pacquiao continued to dictate the pace, repeatedly forcing the Mexican to back-pedal before the Filipino was stunningly knocked out after 2.59 minutes of the sixth round.
“I got hit by a punch I didn’t see,” said Pacquiao, who was ahead 47-46 on the cards of all three judges prior to the knockout.
Saturday’s all-action contest, which featured three knockdowns in just under six rounds before the sensational conclusion, was unquestionably the most exciting of the four between the fighters.
The two boxers battled to a draw in May 2004 before Marquez lost his WBC super-featherweight crown to Pacquiao in a controversial one-point split decision in March 2008.
When they met for a third time, in November 2011, Pacquiao narrowly retained his WBO welterweight title with a controversial majority decision that was greeted by loud booing from disgruntled Marquez fans.