Istanbul (AFP) - Turkey gave a hero's funeral Friday to a policeman praised for preventing a massacre in the latest attack to shake the country, as reports suggested the Istanbul nightclub gunman may still be in the city.

Turkey was shaken just 75 minutes into the New Year by the gun attack on the Reina nightclub in Istanbul that killed 39 people, including 27 foreigners.

Then four days later on Thursday, militants detonated an explosives-packed car in front of the main courthouse in the western city of Izmir and engaged in gun battles with police.

A policeman and a court worker were killed, as well as two attackers. Another was still on the run. Nine people were wounded but their lives are not believed to be in danger.

Whereas Islamic State (IS) jihadists had claimed the Istanbul nightclub attack -- the group's first ever claim of a major attack in Turkey -- the government blamed the Kurdistan Workers' Party (PKK) for the Izmir bloodshed.

Turkish officials led by President Recep Tayyip Erdogan hailed the heroism of slain Izmir policeman Fethi Sekin, who prevented even greater loss of life by stopping the car and then seeking to chase down the militants.

"Did you not see yesterday in Izmir our police officer who jumped like a lion to neutralise the terrorist and was martyred?" Erdogan asked during a rally Friday in Sanliurfa, southeastern Turkey.

Prime Minister Binali Yildirim paid tribute late Thursday to the officer who "prevented a greater disaster by ignoring his own life and by giving his life."

Turkish football team Galatasaray, which Sekin supported, said it would offer an educational scholarship to his son and other opportunities at the club.

- 'Carry on as normal' -

Justice Minister Bekir Bozdag, who attended the ceremony, said 18 people were detained in connection with the Izmir blast and the identity established of the "terrorists", whom he said had planned to wreak havoc inside the court.

Police seized two Kalashnikovs, seven rockets and eight grenades, which Erdogan said proved they had come to commit a "massive massacre".

Story continues

Thousands applauded in emotional scenes as Sekin's coffin was brought out of the Izmir courthouse before being given the rare honour of a funeral ceremony in the city's famous Konak Square.

His body was then to be taken to his home region of Elazig in the east for burial.

The PKK -- proscribed as a terror organisation by Ankara, the United States and European Union -- has been waging an insurgency against Turkey since 1984.

Erdogan said there were people "nourishing, arming, strengthening and directing" groups including the PKK without elaborating further.

The usually peaceful port city of Izmir, Turkey's third largest metropolis, is the gateway to the plush beach resorts of the Aegean and rarely sees violence on this scale. It is well west of the PKK's main theatre in southeastern Turkey.

Yildirim urged Turks to continue their lives as normal, despite the shattering start to the New Year.

"They want to bring people's lives to a halt, sow fear and destroy the values of the country," he said.

- Killer in Istanbul? -

Turkish authorities meanwhile were seeking to close in on the Istanbul club attacker, who slipped into the night after spraying 120 bullets at terrified partygoers celebrating New Year.

While authorities have tightened land and sea borders to prevent the attacker from leaving, the Hurriyet daily said investigators believe he may still be in Istanbul.

It said after the attack, the gunman spent the night in a cafe in the Istanbul district of Zeytinburnu. He took money from the owner and left with two people.

The gunman may have managed to escape by hiding between cars in a car park in the chaos that followed the attack.

Haberturk daily said the attacker was still present even when police first arrived at the Reina, mixing with a group of 10 survivors who were taken out.

Turkish authorities have not named the gunman but Deputy Prime Minister Veysi Kaynak said he was most likely a Uighur.

Most Uighurs, an eastern Turkic group, live in the Xinjiang region of China, although there are also significant populations in ex-Soviet Central Asian states.

Some 40 people have been detained, including in Istanbul and Izmir, over the nightclub attack. Those detained include Uighurs, Kyrgyz citizens and suspects from the Russian Caucasus region of Dagestan.

The latest attacks come after Turkey suffered a bloody year in 2016 with multiple bombings blamed on Kurdish militants and IS jihadists killing hundreds.