Police and Interior Ministry troops regained control of the building about an hour after the crowd of about 2,000 had gathered, shouting slogans in support of the candidate, Urmat Baryaktadasov.
His registration was denied because Kyrgyz officials said they had proof he was a citizen of neighboring Kazakhstan.
The hundreds of protesters who had entered the building were later forced out by police, who then fired tear gas at the crowds outside, briefly dispersing them.
Acting Interior Minister Murat Sutalinov accused Baryaktadasov of organizing the unrest.
"Police were informed that this event might happen, but they did not expect it to be in this form," Sutalinov said.
"(The protesters) are trying to illegally grant candidacy to a citizen of Kazakhstan," he said.
The unrest underscored the high tensions in Kyrgyzstan less than a month before the July 10 vote. The election was called after a March uprising ousted longtime Kyrgyz President Askar Akayev. Seven candidates have been registered to take part in the election, including the front-runner, Acting President Kurmanbek Bakiyev.
Bakiyev became prime minister and acting president after the March 24 uprising. He struck a deal with former security chief Felix Kulov -- under which Bakiyev will choose Kulov as prime minister if elected --
Protesters had occupied the country's Supreme Court for more than a month this spring, complaining that the judges had taken unfair decisions against candidates during February parliamentary elections.
Supporters of rival lawmakers then evicted them from the building on June 1 amid violent clashes.
Violence broke out earlier in the week in the southern city of Osh, when security guards opened fire on market traders demanding fair market prices. Seven people were injured in the clash Monday, two seriously.
The crowd on Friday swept aside approximately 50 policemen and 20 National Guardsman who had been patrolling the building. Police had earlier sealed off the square outside the building.
Up to 100 Interior Ministry troops carrying riot shields and truncheons sealed off entrances to the building after the storming. They then started advancing on the crowd outside the building, beating their shields and causing protesters to break and run.
Police later forced protesters out of the building and out of the courtyard, but the crowds lingered outside. Several forced their way past Interior Ministry troops back into the yard.
Farida Mambetakunova, 35, from Baryaktadasov's home region of Issyk-Kul in northeastern Kyrgyzstan, on the border with Kazakhstan, stood on a flight of steps inside the government headquarters.
"Our goal is to elect him as our president. We will wait here until he is given a mandate to run in the race. We won't leave until then," she said.