A suspect, believed to be the sole perpetrator, was apprehended, police told reporters.
The crime scene extended from the London Pub via a neighbouring club and onwards to a nearby street where the suspect was apprehended a few minutes after the shooting began, police spokesman Tore Barstad told newspaper Aftenposten.
The London Pub is a popular gay bar and nightclub in the centre of Oslo.
"I saw a man arrive with a bag, he picked up a gun and started to shoot," journalist Olav Roenneberg of public broadcster NRK reported.
The motive for the attack was not immediately clear.
Oslo is due to hold its annual Pride parade celebrating the country's LGBTQI community later on Saturday.
"Two people are confirmed dead," the Oslo police department said in a tweet.
Some 14 people were taken to hospital, several with severe injuries, police said.
Photographs published by newspaper VG, broadcaster NRK and others showed a large gathering of emergency responders outside the London Pub, including police and ambulance workers.
Helicopters hovered above central Oslo while ambulance and police sirens were heard across the city.
Oslo's university hospital said it had gone on red alert following the incident.Â