UPDATE 5-Japan bids sombre farewell to slain Shinzo Abe, its longest-serving premier

* Thousands queue to pay respects to Abe at temple, party HQ

* Crowds pack pavements in Tokyo, bow and pray as hearse passes

* Mourners speak of lost sense of security, sadness

* Memorial ceremonies to be held at later date (Adds bullet points)

By Elaine Lies

TOKYO, July 12 (Reuters) - With prayers, flowers and flags draped in black ribbons, Japan on Tuesday said farewell to Shinzo Abe, a polarising figure who dominated politics as the country's longest-serving premier, before being gunned down at a campaign rally last week.

Crowds packed pavements lined with a heavy police presence as the hearse carrying Abe, who died at age 67, departed from a central Tokyo temple on a procession through the city.

With nearly a dozen helicopters circling overhead, people bowed deeply, their hands clasped in prayer, as the hearse passed in a procession carried live on broadcaster NHK. Others clapped, cheered or waved.

"Thank you very much for your work for our country," one man repeatedly shouted.

Hundreds had filed into the temple where Abe's funeral was held on Monday evening and Tuesday morning, prior to the private ceremony, to pay their respects. His killing on Friday by an unemployed man wielding a homemade gun stunned a nation where both gun crime and political violence are extremely rare.

The funeral procession passed through the capital's political heart of Nagatacho, where hundreds had lined up in front of the parliament building Abe first entered as a young lawmaker in 1993, after the death of his politician father.

Prime Minister Fumio Kishida and a group of cabinet ministers waited quietly in front of the office from which Abe, Japan's youngest prime minister when he first took office, led the nation for two stints, the longest from 2012 to 2020, when he resigned due to health problems.

As the hearse slowly passed, Kishida bowed his head, a set of Buddhist rosary beads around his clasped hands. Abe's widow, Akie, bowed back from the front seat of the hearse.

PAYING RESPECTS

From early morning, long lines of people dressed in black, mixed with others in informal clothing with backpacks, formed outside the temple in the sultry summer air.

Keiko Noumi, a 58-year-old teacher, was one of many who came to offer prayers and flowers to a large photograph of Abe set up inside the temple grounds showing him in a simple white shirt, laughing with his hands on his hips

"There was a sense of security when he was the prime minister in charge of the country," she said. "I really supported him, so this is very unfortunate."