Likud's Central Committee on Monday rejected Netanyahu's motion to advance a party leadership election to November in protest at Sharon's removal of soldiers and settlers from Gaza after 38 years of occupation, officials said after the final count.
Sharon's position among Likud hardliners may have been boosted by Israel's killing of an Islamic Jihad leader in Gaza on Sunday in response to Palestinian rocket fire into Israel.
The air strike came as the Likud's Central Committee met.
Benjamin Netanyahu conceded defeat, but said Prime Minister Ariel Sharon cannot ignore the strong opposition against him within the party.
"We lost by a very few votes. There is a very large camp
that went against the flow, against the wind, against the
pressure, against the leadership and against the
temptations," he said.
Sharon's supporters cheered and popped champagne corks as Likud polling officials announced that the prime minister had won by a margin of 51.3% to 47.6%.
Netanyahu is likely to challenge
A Sharon victory averts the threat of early national elections and reduces his chance of bolting the party he co-founded in the 1970s to create a centrist bloc capitalising on majority support for the withdrawal completed on 12 September.
Losing the Central Committee vote deals a sharp blow to Netanyahu, a former prime minister who quit Sharon's cabinet in August to mount his leadership challenge warning that the
pullout would turn Gaza into a "terrorist base".
But Sharon, who once championed the settlers' cause but is now reviled by them as a traitor, still faces a threat of defeat by Netanyahu in the coming party leadership vote in April in advance of a general election that must be held by November 2006.
Sharon had urged the 3000-member committee, a bastion of Likud's traditional nationalist ideology, to keep the party primary as scheduled next year instead of bringing it forward.
Sharon, who billed the move out of Gaza as "disengagement" from conflict with Palestinians, wants to buy time, hoping
There have been several Israeli
air strikes on Gaza
memories of the trauma of uprooted settlers will fade.
The 77-year-old ex-general also hopes to convince Likud's rank-and-file he is their best bet for a third straight term, though many accuse him of betraying Jewish claims on biblical land.
Sharon has tried to mollify Likud's hard-core of rightists by vowing that Israel will never give up large settlement blocs in the West Bank, where 245,000 Jews live isolated from 2.4 million Palestinians.
Netanyahu cited a weekend of rocket attacks as proof the Gaza pullout, the first evacuation of settlements from land Palestinians want for a state, would encourage resistance fighters, who say the withdrawal is a victory.
But many of Likud's power brokers may have feared they would make a weaker showing in national elections against a Sharon-led breakaway party, putting appointments and patronage at risk.
Early on Monday, Israeli aircraft attacked five buildings the army said were used by Hamas and other resistance groups across Gaza for making or storing weapons, despite a pledge by a top Hamas leader to stop the rocket fire.
The violence was the worst threat to a seven-month-old truce since the pullout, which won Sharon international accolades and put pressure on Palestinians to use the strip as a proving ground for statehood in the West Bank and Gaza.