Rowley said the other victims died on Westminster Bridge after the attacker mowed down pedestrians in a car, leaving at least 40 people injured.
Here is what we know about what police are treating as a terrorist attack:
At around 2:40 p.m. local time (1440 GMT), media reported gunfire outside parliament and that several people had been injured in an incident on nearby Westminster Bridge, a busy traffic route that is also a popular tourist spot with its views of parliament and its Big Ben clock tower.
Britain's top anti-terror police officer Mark Rowley said a car had rammed into several people on the bridge, including three police officers.
The car then crashed into railings outside parliament and a knife-wielding attacker tried to enter the building, stabbing a police officer.
Rowley said four people had died, two on the bridge as well as the police officer and the assailant.
"We have declared this as a terrorist incident and the counter-terrorism command are carrying out a full-scale investigation into the attacks," he said.
Timeline of the Westminster attacks https://t.co/eoIN07i12d— The Guardian (@guardian) March 22, 2017
London terrorist attack: what we know so far https://t.co/CKENVm7ceS— The Guardian (@guardian) March 22, 2017
How did authorities respond?
Parliament was swiftly put on lockdown, with lawmakers and staff ordered to remain inside. Hundreds of people were later evacuated from the building.
Police cordoned off a large area in Westminster and tourists on the London Eye, a popular tourist attraction, were stuck more than 400 feet in the air during the incident.
Prime Minister Theresa May, who was in parliament at the time, was ushered away by car and was preparing to chair a meeting of the government's COBRA emergencies committee.
A police spokesman said extra officers would be patrolling the city and urged the public to be vigilant.
Rowley said a "massive operation" was now under way but declined to go into further details.
Television pictures showed a red air ambulance landing on the grass square opposite the parliament building and other emergency vehicles swarming nearby roads.
Westminster Bridge and the nearby Westminster Underground station were closed off.
Home Secretary Amber Rudd said in a video statement: "The government's top priority is the security of its people and I urge everyone to remain calm."
What is known about the attacker?
For the moment, very little. Witness reports described a middle-aged man of South Asian appearance who was carrying a large knife.
A picture published in British media showed a bearded man wearing a dark top, said to be the assailant, on a stretcher being treated by medics.
"We currently believe there was only one attacker," Rowley said.
Has anything like this happened in London before?
London's transport system was hit by four co-ordinated suicide bomb attacks in July 2005 that left 52 people dead, carried out by British attackers inspired by Al-Qaeda terror network. There was an attempted second wave of attacks two weeks later.
In 2013, two Islamic extremists killed soldier Lee Rigby on a London street by hitting him with a car before attempting to behead him.
Last August, a paranoid schizophrenic knifeman who tried to behead a commuter in a London Underground station in an Islamic State-inspired attack was sentenced to life behind bars.
In terms of attacks on parliament, Airey Neave — the shadow Northern Ireland Secretary and a close friend of Conservative Party leader Margaret Thatcher — was killed by an Irish National Liberation Army car bomb in the House of Commons car park.
The latest incident comes with Europe on high alert after a series of deadly jihadist attacks, including the Brussels bombings exactly a year ago on March 22, 2016.