A federal judge in Baltimore has ordered Maryland election officials to include a libertarian candidate on the ballot in the special 5th District congressional election May 17, provided he has collected enough signatures to satisfy the requirements of state law.

Tom Mathers, a 31-year-pld employe of a stock exchange monitoring firm who announced his candidacy six weeks ago, was told by state election officials on March 16, the filing deadline for all candiates in the race, that he would not be included on the ballot because he had not collected the necessary number of valid voter signatures.

State election law requires that candidates who are not members of recognized parties, which in Maryland means the Democratic or Republican parties, must collect the signatures of 3 percent of the election district's registered voters. In the 5th District, which includes northern Prince George's County and a silver of Montgomery County, the three precent translates into 5,436 signatures.

As of the filing deadline, Mathers had collected only 908 valid signatures in support of his candidacy. Mathers said at the time that it was impossible for him to have collected more because of the speed with which the election to replace Gladys Spellman was called and the filing deadline, just 17 days after the special election, was set.

As a result he filed suit. charging that the state law was unfair to those not affiliated with the Democratic or Republican parties and asked to be given more time to collect signatures.

Federal District Court Judge Joseph H. Young, in a decision to be released Monday, agreed with Mather's request and said the state board must now consider some 7,800 additional signatures that Mathers collected between the filing deadline and the special primaries for the seat that were held April 7.

Young said that if election officials determine that Mathers had collected the necessary signatures, he will join Democrat Steny Hoyer and Republican Audrey Scott on the May 19 ballot as as Independent, but without being identified as a Libertarian, as Mathers had sought.

Lawyers for Mathers and for the state attorney general said yesterday they are considering appealing Young's decision.