Three people have died after a siege in a Sydney café that came to a dramatic end when armed police stormed the building, following a standoff that had dragged on for more than 16 hours.
New South Wales police said the victims included a 34-year old man, a 38-year-old woman and the gunman, Man Haron Monis.
Heavy gunfire and loud bangs from stun grenades filled the air shortly after 2am local time.
Moments earlier at least six people believed to have been held captive managed to flee the scene after several loud bangs were heard coming from the café.
Medics were seen trying to resuscitate one person after the raid and took away several injured people on stretchers, said a witness at the scene in downtown Sydney.
Police said one woman was treated for a gunshot wound to her shoulder while two other women were taken to hospital with non-life threatening injuries.
A police officer also received injuries to his face from gunshot pellets.
Australian Prime Minister Tony Abbott said the gunman was well known to authorities and had a history of mental instability.
"The perpetrator was well known to both state and commonwealth authorities," Mr Abbott told reporters in a brief press conference in Canberra.
"He had a long history of violent crime, infatuation with extremism and mental instability," he said.
"These events do demonstrate that even a country as free, as open, as generous and as safe as ours is vulnerable to acts of politically motivated violence," Mr Abbott said.
Earlier, New South Wales Police Commissioner Andrew Scipione said 17 hostages, including five who escaped in the early hours of the siege, had been accounted for.
He urged people not to "speculate" or "develop theories"
about what happened inside the café and said police believed more lives could have been lost if officers had not entered the café at that point.
He said that gunfire at the café prompted police to move in.
The Professional Standards Command will now oversee a critical incident investigation, which is standard procedure for situations in which police officers fire their weapons.
Mr Scipione said the uninjured hostages would be interviewed as part of that investigation: "We need to talk to them. They're being looked after in terms of their psychological needs ... family are involved in this process."
He added that the Lindt café had been secured and no explosive devices found.
NSW Premier Mike Baird said: "Our first thoughts and prayers this morning are with the innocent victims of this horrendous and vicious attack.
"I want to say to their family and friends, everyone in NSW stands beside you."
Mr Scipione said a number of hostages had "traumatic injuries" and some had "medical conditions".
"We also have a lone gunman who has been shot and killed and we have a male police officer who has been injured as a result of a gunshot wound to the face."
He added that the injured officer was in a "good condition" and was being assessed in hospital.
"He is well and grateful to be alive, let me assure you," Mr Scipione said.
The commissioner said: "This was an isolated incident, it is an isolated incident. Do not let this sort of incident bring about any loss of confidence about working or visiting in our city.
"It was the act of an individual. This should never change or destroy the way of our life. This won't change our lives, this will not change the things we hold dear in this country."
Earlier, Prime Minister Abbott said in a statement: "Australians awoke to the news this morning that the siege in Martin Place had ended.
"Our thoughts and prayers are with the families of the two deceased hostages, the wounded and the other hostages.
"I commend the courage and professionalism of the New South Wales Police and other emergency services involved."
The operation to enter the café began shortly after a police source named the gunman as Man Haron Monis, an Iranian refugee and self-styled sheikh facing multiple charges of sexual assault as well as being an accessory to murder.
He was also found guilty in 2012 of sending offensive and threatening letters to families of eight Australian soldiers killed in Afghanistan, as a protest against Australia's involvement in the conflict, according to local media reports.
The Iranian government has condemned the hostage taking.
Although he was well known to the authorities, security experts said preventing attacks by people acting alone could still be difficult.
"Today's crisis throws into sharp relief the dangers of lone wolf terrorism," said Cornell University law professor Jens David Ohlin, speaking in New York.
"There are two areas of concern. The first is ISIS (Islamic State) fighters with foreign passports who return to their home countries to commit acts of terrorism.
"The second is ISIS sympathisers radicalised on the internet who take it upon themselves to commit terrorist attacks to fulfill their radical ideology.
"We are entering a new phase of terrorism that is far more dangerous, and more difficult to defeat, than al-Qaeda ever was."
During the siege, hostages had been forced to display an Islamic flag, igniting fears of a jihadist attack.
Australia, a staunch ally of the United States and its escalating action against Islamic State in Syria and Iraq, is on high alert for attacks by home-grown militants returning from fighting in the Middle East.
News footage showed hostages holding up a black and white flag displaying the Shahada - a testament to the faith of Muslims. The flag has been popular among Sunni Islamist militant groups such as Islamic State and al-Qaeda.
At least five hostages were released or escaped, with terrified café workers and customers running into the arms of police.
A further 15 or so hostages were understood to have been holed up inside the cafe.
The incident forced the evacuation of nearby buildings and sent shockwaves around a country where many people were turning their attention to the Christmas holiday following earlier security scares.
In September, anti-terrorism police said they had thwarted an imminent threat to behead a random member of the public and days later, a teenager in the city of Melbourne was shot dead after attacking two anti-terrorism officers with a knife.
The siege cafe is in Martin Place, a pedestrian strip popular with workers on a lunch break, which was revealed as a potential location for the thwarted beheading.
In the biggest security operation in Sydney since a bombing at the Hilton Hotel killed two people in 1978, major banks closed their offices in the central business district and people were told to avoid the area.
Muslim leaders urged calm. The Australian National Imams Council condemned "this criminal act unequivocally" in a joint statement with the Grand Mufti of Australia.
Concerns about an attack in Australia by Islamists have been growing for more than a year, with the security agency raising its national terrorism public alert to "high" in September.
Snipers and a SWAT team took up positions around the café and police helicopters flew overhead.
The Reserve Bank of Australia said staff had been locked down inside the building and were all safe.
The nearby US consulate was also evacuated, according to an embassy spokeswoman, along with the Sydney Opera House.
Tourists were being let back into the world-famous venue by early afternoon but performances today and tomorrow were cancelled.
Flanagan extends sympathies of Irish people
Minister for Foreign Affairs and Trade, Charlie Flanagan extended his sympathies to the Australian people following today's tragedy.
Minister Flanagan said: "This attack on innocent citizens is a deeply distressing event.
"My thoughts and prayers and those of Irish people everywhere are with the families of the deceased hostages, with the injured and with all the innocent victims of this appalling attack.
"We stand with our friends in Australia at this difficult time," he said.
"Through our Embassy in Canberra and our Consulate in Sydney, we remain in close contact with the Australian authorities."