(Adds recount, details)
By Jim Loney
KINGSTON, Sept 3 (Reuters) - The opposition Jamaica Labour Party appeared to win power in a cliffhanger election on Monday but the ruling party, facing the end of an 18-year reign, served notice it would likely challenge the result.
Election officials said the JLP won 31 of the 60 seats in parliament in a preliminary vote count. If the result stands, it would mean a quick end to the tenure of Portia Simpson Miller, Jamaica's first woman prime minister, who took over the leadership of the People's National Party 18 months ago.
Raucous celebrations erupted in Jamaica's capital. Hundreds of JLP supporters, wearing party green and waving tree branches, cheered at party headquarters and paraded in noisy motorcades through the streets.
But Simpson Miller, in a brief address to glum supporters, said she was not going to concede defeat before the results were final and had been examined closely.
"The election is too close to call," said Simpson Miller, seeking her first election mandate after replacing retiring prime minister P.J. Patterson last year. "As of now we are conceding no victory to the Jamaica Labour Party."
Director of elections Danville Walker said workers would begin recounting ballots on Tuesday and the process could take two to three days. He said there were about three constituencies that were "closer than razor thin"
Citing voting irregularities, Simpson Miller said PNP candidates could file legal challenges.
"In some constituencies people were barred from exercising their right to vote," she said, adding people were campaigning illegally and votes were bought. "We have this evidence."
JLP leader Bruce Golding, also contesting his first election as party chief, had not yet spoken.
THREATS OF VIOLENCE
Jamaicans defied long lines at polling stations, threats of violence and the fringes of a hurricane to vote in an election already a week delayed by the passage of Hurricane Dean 15 days ago.
Rain from the fringes of Hurricane Felix soaked parts of the island as the powerful storm churned 250 miles (400 km) to the south and large sea swells flooded the road to Kingston's airport.
Election officials reported a few glitches including delayed poll openings and one incident of gunfire near a Kingston voting station.
But the Caribbean island of 2.8 million people appeared to have largely escaped election day violence, after at least 10 people died over the weekend in shootings that provided a tense reminder of past political violence.
Thousands of police and soldiers were assigned to keep the peace. Camouflage-clad troops carrying rifles were seen at some polling stations.
There was widespread grumbling that lines at the polls were too long, in part because of new electronic voter ID cards and other measures to cut down on fraud.
"It's a good feeling to be voting in my first election but the process was too long and too slow," said Karl Kennedy, who cast his ballot at a Kingston polling station.
Analysts said Golding benefited from Jamaicans' desire for change after 18 years of PNP rule, along with the island's unemployment rate of 9 percent, sluggish economic growth and a murder rate averaging 1,200 per year, among the highest in the world.
"I am voting for the JLP. This country needs a change and we will get that change today," said Jennifer Somers, an early voter at a polling station north of the capital.
Parts of the verdant island remained under repair after Dean's passage on Aug. 19. The storm killed five people, tore apart homes and destroyed 90 percent of the banana crop. (Additional reporting by Horace Helps in Kingston)