It was the classic tax squabble pitting the taxpayer against the system, but this time the protesting taxpayer was a former highranking IRS official and yesterday the Maryland courts said he must pay.

"Sure, some people will love it," said Irving Machiz, the loser in a five-year battle with Maryland tax officials over a $2,200 bill. "They'll say it serves him right."

But to Machiz, the retired head of the Internal Revenue Service for Maryland and the District of Columbia, "That's not the important thing. It's a matter of law."

The 66-year-old Machiz has argued for nearly five years that he should not have to pay most of his 1974 Maryland income tax bill because his principal place of residence and his domicile was Florida that year.

The Maryland comptroller's office disagreed, and yesterday the state Court of Special Appeals ruled in the office's favor.

The first lesson to be learned in the the case, Chief Judge Richard Gilbert wrote, is that "former tax collectors do not like to pay income taxes any more than other taxpayers."

But Machiz, retired and living in Fort Lauderdale, sees it differently.

"It's a matter of principle," he said yesterday. "I believe everyone should pay their taxes, but I always preach, 'only pay what you owe . . . not what you don't owe.'"

Machiz, who retired in 1972 after nearly 30 years with the IRS, has argued through a series of hearings and trials that his legal "domicile"-true permanent home-was Florida in the year 1974. To back up his claim, Machiz pointed out that he bought a condominium in Florida in 1972, that he registered to vote in Florida, that he usually spent more than seven months a year in Florida, and that he signed a real estate contract to sell his Baltimore County home in 1974.

But Assistant Maryland Attorney General Gerald Langbaum argued to the court that Machiz still owned his home in Maryland in 1974, conducted his business activities in Maryland that year, possessed a Maryland driver's license and had two cars registered in the state.

Based on these and other findings, the Maryland tax court ruled in 1976 in the state's favor. Machiz appealed and won in a Baltimore County Circuit Court.

Then, the state comptroller's office appealed, and the state's second-highest court ruled yesterday that the tax court's original findings were supported by substantial evidence.

Machiz pointed out yesterday that he paid some Maryland income tax in 1974-the part he believed he owed. And he took yesterday's ruling stoically.

"Well, these things happen," he said. "I'll appeal."

The comptroller's office took the ruling a stride, too. "It's a fitting ending," said spokesman Marvin Bond, "for the 1979 income tax season."