Both sides blamed the other for the shooting. In a statement, police said two officers were shot and wounded in the legs, and six other officers were injured by individuals using clubs and stones.
But Abdullahi Muhammad Musa, a protester and member of the Islamic Movement of Nigeria (IMN), told Reuters that police fired the shots, killing two protesters, after they peacefully tried to enter the assembly building.
IMN, a group that represents Nigeria's minority Shia Muslims, has protested regularly outside the National Assembly, calling for the release of their leader, Ibrahim Zakzaky, who has been in detention since 2015.
Nigerian security forces have killed some 400 members of the group in response to largely peaceful protests since 2015, according to human rights groups.
Police said they had arrested 40 protesters during Tuesday's incident.
The assembly remained on lockdown as of late afternoon. In a statement, the police force said they had "used minimum force to disperse the unruly protesters."
Witnesses said police used tear gas against the protesters, and smoke could be seen coming from the area.