Before he was cornered, the man attacked drivers and passengers on a road near the Guangqumen Bridge, the Beijing Municipal Public Security Bureau said in a statement.
Of the three person attacked, two died at a hospital after emergency medical treatment failed and the other one was still under treatment, state-run news agency Xinhua reported.
The attacker was later besieged inside a private car by police officers and citizens. He later died at hospital from injuries, the report said.
Knife attacks are not new in China. In a recent incident, a man wielding a knife stabbed an elderly woman and 22 children outside an elementary school in in Henan Province last December.