It was sweet revenge for Meares, who lost to the British rider in the final four years ago in Beijing. She denied Pendleton a third gold medal, which would have made her the most successful British female athlete at the Olympics.
Pendleton has said she will retire after the London Games.
"I am just so relieved right now, I am just so overwhelmed with emotion," an emotional Pendleton said. "I would have loved to have won in my final race. At the same time, I am just so glad I am done and I can move on."
Guo Shuang of China won the bronze with a 2-0 win over Kristina Vogel of Germany on the final day of track competition.
The 31-year-old Pendleton thought she had got off to a strong start in the final after beating Meares by one thousandth of a second. But the defending champion was relegated a few minutes later for coming out of the sprinter lane.
She never looked in contention in the second bout after Meares track standed to force her to go in front. Meares then rounded Pendleton on the outside to claim the gold medal in track cycling's marquee event.
Meares punched the air before crossing the line then shed her visor before joining hands with Pendleton, her best rival over the past decade.
"Victoria's such a hard-fought opponent and she's dominated the sport for so long," Meares said. "It's been such a difficult challenge and to be able to win the Olympic title for me, it's so special. I've tried so much and worked so hard for a long period of time and I've asked a lot of people around me to do the same so it feels like this is a just reward."
Pendleton, who had been relegated in the team sprint before she bounced back with the gold medal in the keirin, was in tears but found some consolation when the capacity crowd started to chant "Vicky, Vicky, Vicky!"
"I am glad it got to that stage because I believe she's the best rider on the field," Pendleton said. "Anna and myself in the final. We have met many a time. I wish her all the best. I am glad to say that this is the last time I have to go through this."
Meares had started the first leg on the outside of the track. She produced her effort in the final lap to move next to Pendleton in the final curve. Meares touched her rival with her left arm in the home stretch in a furious sprint to the line and officials needed a photo finish before announcing that Pendleton had won the leg by one thousand of a second, the smallest possible margin.
British cycling director of performance Dave Brailsford was then spotted chatting with officials seconds before the speaker said that Pendleton was relegated.
"I was really annoyed because I was sure that she touched me and it caused me to move up," Pendleton said. "I cannot believe twice in one competition that I have been relegated, disqualified, it's unheard of. It's a bit of a surprise. It did knock my confidence a bit, I have to say."
Meares and Pendleton both have multiple world titles and a bitter rivalry that escalated at the 2006 world championships in Bordeaux, France, where the British rider accused her rival of cutting her off in a keirin race.
Pendleton then beat Meares in the final in Beijing but Meares had the upper hand at the 2011 world championships. Pendleton regained the world title in Melbourne, Australia, handing Meares a painful defeat in the Australian's backyard.
After being relegated in the team sprint event in London, Pendleton bounced back with a gold medal in the keirin, where Meares finished a disappointing fifth.
The Australian was injured in a crash during the keirin final of a World Cup event in Los Angeles on January 2008, sustaining a hairline fracture to one of her vertebra, some torn muscles in her neck, a dislocated right shoulder and torn tendons in her shoulder.
Doctors said at the time that the crash could have left her paralyzed. She returned to competition just six months after the accident to win silver in Beijing.Suggest a correction