The former head of the visa section at the U.S. Embassy in Madrid has been indicted by a grand jury in Miami in connection with an alleged ring that sold visitor visas to Iranians for as much as $5,000 each.

Bernard Joshua Fennell, 44, a 19-year veteran of the Foreign Service, was arrested late Tuesday at the State Department by officers of the department's Bureau of Diplomatic Security and was freed on $25,000 unsecured bond after appearing yesterday before U.S. Magistrate Arthur Burnett.

The indictment, which was handed up late last year in Miami but unsealed only Tuesday, charges Fennell with illegally providing the visas to seven Iranian nationals through a naturalized U.S. citizen, Harry Arjad, who formerly held Iranian citizenship. In each case, the indictment says, Arjad was paid to secure the visas.

Fennell, who has been put on administrative leave, made no statement at the brief removal hearing, but Burnett ordered him to surrender his diplomat's passport by noon today. He is to be arraigned Tuesday in Miami.

State Department spokesman Bruce Ammerman said last night that Fennell, who had been deputy chief of the Madrid consular section since 1984, was recalled to Washington on Feb. 24. The department's investigation began last August after the diplomatic security bureau "became aware of irregularities" at the visa section in Madrid.

Fennell's attorney, William W. Bennett, said Fennell is a graduate of Florida A&M and has a masters degree from Harvard Business School.

According to court records, Fennell, of 14632 Tynewick Terrace, Silver Spring, was posted to Montevideo, Uruguay, from 1981 to 1984, after duty in Fiji and England.

The court records also show that Fennell is receiving therapy for an "emotional problem" caused by an accident.

Ammerman said 40,703 visitor, or nonimmigrant, visas were issued worldwide to Iranian nationals in fiscal 1986. Such visas are issued only to persons who are expected to return to countries with which they have clear ties.

According to the 21-count indictment, in which Fennell is charged in 10 counts, Fennell met with Arjad in Los Angeles last June. The next month, Saeid Fegiram, who was also charged in the indictment, paid Arjad $5,000 to "obtain an unlawfully issued nonimmigrant United States visa." Fennell issued the visa in Madrid on Aug. 1. Fegiram tried to enter the country at Miami International Airport on Oct. 16.

According to the indictment, Arjad was subsequently paid a total of $27,500 for nine other visas issued by Fennell in Madrid.

If convicted on all counts, Fennell could face 50 years in prison.