The Federal Communications Commission yesterday upheld a Carter-Mondale election committee complaint that the television networks acted illegally in refusing to sell President Carter a half hour of prime time next month to announce his candidacy.

The commission, in a surprise 4-3 vote, gave ABC, NBC and CBS until Monday to respond with their plans to comply with the commission order that they provide Carter with "reasonable access" to the airwaves.

The networks said they are studying the order.

The vote was strictly along party lines, with Democratic Chairman Charles Ferris and commissioners Tyrone Brown, Joseph Fogarty and James Quello voting for the committee's complaint. Republicans Ann Jones, a Carter appointee; Abbott M. Washburn and Robert E. Lee voted for the networks.

Quello's vote was the major surprise. Although he is a Democrat and he faces reappointment this spring, Quello generally votes on the side of the broadcasters.

During yesterday's debate, which lasted more than an hour, Quello started by repeating a contention that the "reasonable access" statute under which the Carter-Mondale committee complaint had been filed was unconstitional and in violation of the First Amendment.

But he then surprised commission observers by adding that since the standard was on the books, it had to be enforced, and he voted against the networks.

When the committee's media adviser, Gerald Rafshoon, requested the half-hour time slot from the three networks, they each responded differently. NBC gave a flat no, ABC said they could not grant the half hour until January at the earliest, and CBS offered two 5-minute segments.

Basically, the networks argued that the large number of candidates would make it impossible to offer a half hour to anyone, because the others would want the same. In addition, they said the request was too early in the campaign and that such a large chunk of time would cause "programming disruption."

But the FCC rejected those arguments, concluding instead that since the networks were spending so much time covering the political campaigns on their news shows, the argument that the timing was too early in the campaign was without merit.

The commission also contended that the importance of the job at stake out-weighed the problems of having about a dozen candidates to accommodate and that the networks were juggling so many shows in the ratings war that they could not claim that one half-hour program was too disruptive.

Andrew Schwartzman of the Media Access Project, a broadcast consumer group, hailed the decision. "This decision puts the horse back in front of the cart. The FCC has again protected the public's right to receive information," he said.

Schwartzman said it was ironic that normally pro-broadcaster Quello cast the decisive vote. "All the same," Schwartzman said, "we're sure that President Carter will look to Quello's generally abominalbe record and appoint someone else."