Ahmadinejad supporters took only 13 of the 65 seats in contention in runoff elections Friday while candidates allied to Khamenei and the Islamic Republic's conservative clerical establishment swept 41.
That left Ahmadinejad, elected in 2005 and heading into the final years of his second term, vastly outnumbered by conservatives in the 290-member Majlis, or Parliament.
He had lost heavily in the first round of voting in March to parties aligned with Khamenei.
Khamenei's assertion of his authority and that of the conservative leadership occurred in advance of the crucial May 23 meeting in Baghdad between Iran and the Western powers it is confronting in the Persian Gulf over Iran's contentious nuclear program.
The election results are unlikely to have any direct impact on that gathering, or on Iranian nuclear policy which is determined by Khamenei. Parliament has no control over nuclear policy.
But analysts believe that with Ahmadinejad firmly sidelined, Khamenei may feel secure enough to cut some sort of deal in Baghdad that will defuse tensions, in return for an easing of increasingly tough economic sanctions that are throttling Iran's all-important oil exports and crippling an already bruised economy.
At a preliminary meeting in Istanbul April 13-14, the Iranians showed some signs of being prepared to make some concessions on uranium enrichment, a process crucial to developing nuclear weapons, if the United States and its allies ease off on the sanctions.
"Contrary to the convenient argument that Khamenei resists agreement with the United States, he and leading officials on the Supreme National Security Council have long viewed negotiations with the United States as the only way that Iran can achieve full security and emerge as a full-fledged regional power," observed U.S. analyst and historian Gareth Porter.
Khamenei is seen as more pragmatic than the confrontational Ahmadinejad, and without being seen to surrender Iranian sovereignty clearly would prefer to hand over power to his hand-picked successor under more stable circumstances than currently exist.
Ahmadinejad's challenge to Khomeini's legacy and Islamic Revolution's Old Guard was highly offensive to Khamenei, who had mentored the younger man's political rise and endorsed his re-election in 2009 amid widespread allegations of vote-rigging that triggered unprecedented riots.
But Ahmadinejad, re-elected, launched his campaign to wrest power to the presidency, which has been firmly controlled by the clerical leadership since Khomeini's revolution.
Ahmadinejad's political fortunes began to collapse after he openly defied Khamenei in April 2011 by appointing one of his closest aides intelligence chief and then sought to expand the authority of the presidency at the expense of the clerical leadership.
The Majlis had also once embraced Ahmadinejad and his populist program.
But it turned against him two years ago when he challenged the authority of senior clerics such as Khamenei, constitutionally the ultimate power who controls the powerful Islamic Revolutionary Guard Corps and the intelligence and security services.
A few months ago, Ahmadinejad faced possible impeachment for his audacious and unprecedented challenge to the clerical leadership that has ruled Iran since the late Ayatollah Ruhollah Khomeini's Islamic Revolution toppled Shah Mohammad Reza Pahlavi in early 1979.
The prospect of impeachment has diminished somewhat with Khamenei's decisive victory in the Majlis elections, but his closest political allies are being undergoing judicial investigation while Khamenei is placing his inner circle into key government positions to further isolate Ahmadinejad over the final months of his turbulent presidency.
Khamenei has been supreme leader since he succeeded Khomeini following his death in 1989. He's scheduled to step down in 2014 and is clearly preparing the ground for whoever he selects to replace him.
The coming weeks will indicate whether Ahmadinejad will throw in the towel and submit to Khamenei's authority. There are concerns he will remain defiant.
Iran has portrayed the parliamentary elections as a demonstration of support for Iran's religious leadership in their faceoff with the West over Tehran's nuclear program.
"The vote is support for the ruling system as it faces the United States and its allies over the nuclear program," noted political analyst Reza Khamesian.
"The vote also means that tensions will increase between Ahmadinejad and his opponents in the incoming Parliament."
Notable deaths of 2014 [PHOTOS]