Dozens of people were also wounded in the attacks, with continuing gunfire several hours after they began.
A security guard and one other person were killed when four gunmen burst into Tehran's parliament complex with rifles and a pistol, according to the ISNA news agency.
Islamic State published a 24-second video which purports to show the parliament siege.
The video, circulated online, shows a gunman and a bloody, lifeless body of a man lying on the ground next to a desk.
A voice on the video praises God and says in Arabic: "Do you think we will leave? We will remain, God willing."
One of the attackers blew himself up on the fourth floor of the parliament office building as a standoff with police continued for several hours.
It's believed the attackers were dressed as women and entered parliament's main gate before opening fire.
In the coordinated mid-morning attack, a gardener was reported dead and several more injured when armed assailants entered the grounds of Ruhollah Khomeini mausoleum in the south of the city.
Two attackers - at least one female - blew themselves up outside the shrine, according to local media.
Iran's emergency services said they were dealing with 33 injured from the attacks and that two people had died from their injuries in hospital.
IS claimed the attacks in a report from its Amaq propaganda agency which said: "Fighters from the Islamic State attacked the Khomeini mausoleum and the parliament building in Tehran."
It also claimed two suicide bombers had blown themselves up at the shrine.
Parliament was in session as the attacks unfolded, with live footage showing members continuing with routine business even as gun battles were reported in surrounding office buildings and snipers took position on nearby rooftops.
Speaker Ali Larijani dismissed the attacks, saying they were a "trivial matter" and that security forces were dealing with them.
Intensified gunfire was heard from the neighbouring offices as Fars news agency reported police had launched an assault. A picture on social media showed police helping staff escape through windows.
Iranian police said they had arrested five suspects over the attacks and the country's supreme leader, Ayatollah Ali Khamenei, struck a defiant tone.

Iranian policemen try to help some civilians fleeing from the parliament building during an attack in Tehran, Iran. (FARS NEWS AGENCY) Source: FARS NEWS AGENCY
"These fireworks have no effect on Iran. They will soon be eliminated ... They are too small to affect the will of the Iranian nation and its officials," state TV quoted him saying.
Khamenei added that Iran, which is helping Syrian President Bashar al-Assad fight rebels including Islamic State fighters, had prevented worse attacks through its foreign policy.
The powerful Islamic Revolutionary Guard Corps accused Riyadh of being behind the attacks and vowed to seek revenge.
"This terrorist attack happened only a week after the meeting between the U.S. president (Donald Trump) and the (Saudi) backward leaders who support terrorists. The fact that Islamic State has claimed responsibility proves that they were involved in the brutal attack," a Guards statement said.
The deputy head of the Guards, Brigadier General Hossein Salami, was quoted later by Tasnim news agency as saying: "We will take revenge on terrorists and their supporters who martyred our people."
Saudi Foreign Minister Adel Al-Jubeir, speaking in Berlin, said he did not know who was responsible for the attacks and said there was no evidence Saudi extremists were involved.
The US State Department and U.N. Secretary-General Antonio Guterres both condemned the attacks.
US President Donald Trump expressed sympathy for the victims of a terror attack in Iran, but issued a barbed warning that the country was reaping what it sowed.
"We grieve and pray for the innocent victims of the terrorist attacks in Iran, and for the Iranian people, who are going through such challenging times," Trump said in a brief statement.
"We underscore that states that sponsor terrorism risk falling victim to the evil they promote."
Australian Foreign Minister Julie Bishop has denounced the terror attacks.
"We extend our deep condolences and sympathy to the victims and their families, and the Iranian people," Ms Bishop said.
Ms Bishop has spoken to Australia's ambassador in Tehran who has confirmed that all embassy staff are safe.
Shrine attack
An official at Khomeini's mausoleum in south Tehran said "three or four" people had entered via the western entrance and opened fire, killing the gardener and wounding several people, according to Fars.
The news agency published photos showing the suicide bomber blowing herself up outside.
The shrine lies around 20 kilometres away from parliament and houses the body of Khomeini, who led the Islamic revolution in 1979.
The ILNA news agency said security forces were dismantling a bomb inside the shrine and that firing was still going on around the site.
The intelligence ministry claimed there was a third "terrorist" team that had been neutralised before the attacks started.
The city was on lockdown, with streets blocked and parts of the metro closed. Journalists were kept away from the shrine by police.
Interior Minister Abdolrahman Fazli told ISNA he had convened a special meeting of the country's security council.
Targeted by IS
Jihadist groups have clashed frequently with security forces along Iran's borders with Iraq and Afghanistan, but the country has largely escaped attacks within its urban centres.
Iran, the predominant Shiite power, has been helping both Iraq and President Bashar al-Assad's regime in Syria to battle IS.
The jihadist group is under increasing pressure in both countries, having lost significant territory in the face of offensives now targeting its last two major urban bastions, Raqa in Syria and Mosul in Iraq.
IS published a rare video in Persian in March, warning that it "will conquer Iran and restore it to the Sunni Muslim nation as it was before."
IS and other extremists consider Shiites to be apostates, and the video accuses Iranians of persecuting Sunnis over the centuries and into modern times.
Militant groups are also known to operate in Iran's southeastern Sistan-Baluchistan province, which borders Pakistan and has a large Sunni community.
Jaish-ul Adl (Army of Justice), which Tehran accuses of links with Al-Qaeda, has carried out several armed attacks inside Iranian territory in recent years.
The attacks could also exacerbate tensions in Iran between newly re-elected President Hassan Rouhani, a pragmatist who positions himself as a reformer, and his rivals among hardline clerics and the powerful Revolutionary Guards.
But Rouhani said they would make Iran more united and more determined in the fight against regional terrorism and violence.
"We will prove once again that we will crush the enemies' plots with more unity and more strength," he said.
In an appeal for unity, Rouhani’s chief of staff, Hamid Aboutalebi, took to Twitter to praise the security services.
"Applause to the power and firmness of our revolutionary guards, Basij, police and security forces," he wrote.