"The attackers fired with pump rifles at the party headquarters at 4:05 am from a passing car," an official from the pro-Kurdish People's Democratic Party (HDP) told AFP on condition of anonymity.
Security guards protecting the building responded and the assailants fled, according to the official, who added that there were no casualties.
Another HDP lawmaker, Sirri Sureyya Onder, called the attack a "provocation" ahead of June 7 legislative elections.
"Provocation is continuing. We will not yield," he wrote on Twitter.
More From This Section
"Arms mean provocation. Some dirty hands step in at election times and try to create provocation," Deputy Prime Minister Yalcin Akdogan was quoted as saying by the state-run Anatolia news agency.
"No matter where it comes... We always condemn terror regardless of its target or origin," he said.
Tensions are running high ahead of the key June legislative elections. In a tight battle, the HDP is seeking to win more than 10 per cent of the vote to qualify for direct representation in parliament.
Should it succeed, it could derail a bid by the ruling Justice and Development Party (AKP) to change the basic law and create a presidential system -- for which the AKP would need the support of two-thirds of parliament's 550 members.
Onder, who later visited the party building in the Cankaya district, said he did not know how many assailants were in the car, adding that the attack was an attempt to prevent the party from clearing the 10 percent threshold.
"We are determined to insistently advocate peace and democratic policies," he told reporters.