epublican J. Marshall Coleman, while trailing in recent polls, has both outraised and outspent Democrat Charles S. Robb in what already has become the costliest gubernatorial campaign in Virginia history.

Financial statements filed today with the State Board of Elections showed that through Sept. 29, Coleman had raised $1.8 million to Robb's $1.5 million and had outspent Robb $1.7 million to $1.2 million. Coleman, the state's attorney general, spent heavily on media and direct mail early in the campaign in an effort to close a name-recognition gap his advisers said he suffered with Robb, the state's lieutenant governor and son-in-law of the late president Lyndon B. Johnson.

The statements also suggest that Robb may have a key spending advantage during the final four weeks of the campaign. Robb today reported having $410,776 in the bank, compared with $121,290 for Coleman.

Both candidates originally had planned to spend around $2 million, but the Coleman camp already is talking about spending $2.9 million, while Robb strategists say their spending may hit $2.5 million.

At this time four years ago, Republican John N. Dalton had raised $1.2 million, compared with only $306,000 for Democrat Henry E. Howell. Dalton went on to beat Howell with the candidates spending a combined total of $2.7 million -- about $600,000 less than Coleman and Robb already have raised this year.

The biggest source of money for both candidates this year has been coal operators in Southwest Virginia. According to a preliminary survey of the contributors' lists, Robb has received $242,537 from coal and other energy suppliers, while Coleman reported $193,999 from those same sources. Both men have pledged to oppose any increase in state coal taxes and have called for the relaxation of federal strip-mining restrictions.

Conspicuous by its absence today was organized labor, which in 1977 was the single largest donor to the Howell campaign, giving the Democratic nominee more than $310,000. So far this year, Robb has received $11,000 from nine unions, while Coleman has not gotten any labor money.

Despite charges and countercharges about out-of-state contributors, particularly from Texas, both candidates appear to be faring equally in non-Virginia contributions. Robb reported that $233,229, or about 15 percent of his money, came from beyond Virginia's borders, including $49,098 from Texas, home of his Johnson in-laws. More than half of that came from mother-in-law Lady Bird Johnson, who contributed $21,400, and sister-in-law Luci Baines Johnson who donated $5,000.

Coleman's out-of-state contributions totaled $192,000, including about $30,000 raised at two fund-raisers at the Petroleum clubs of Dallas and Houston last month.

The Coleman out-of-state total does not include $110,000 from the Republican National Committee, which this week also dispatched its own political strategist here to aid a campaign that many national Republicans contend is faltering. Coleman also collected $51,030 from the Republican Party of Virginia, which was used for his direct-mail effort.

By contrast, Robb reported a total of $20,000 from the state Democratic Party and $10,100 from the Democratic National Committee.

Robb did far better with another traditional source of campaign funds, the state's influential real estate and construction industries, to whom he has promised to funnel millions of dollars in state retirement funds to bolster the state's depressed housing market. He reported $166,249 from real estate interests and another $75,831 from construction companies and contractors.

Coleman reported only $49,725 from real estate groups and $23,313 from builders and contractors, some of whom have been upset with his pledge to veto any state tax increase including money for state highway construction.

Coleman's totals from specific industries may actually be higher because many of his donors were not identified by occupation as state law requires. Stan Maupin, Coleman's treasurer, said the campaign made a good-faith effort to persuade contributors to identify their occupations but that many had simply refused to do so.

Television and radio advertising was the area of greatest spending by both candidates. Coleman's media consultant, Bailey, Deardourff and Associates of McLean, had been given $495,766 through the end of September. Coleman's direct-mail firm, North American Marketing of Richmond, had spent $51,981, and the public opinion firm DMI of Santa Ana, Calif., operated by President Reagan's pollster, Richard Wirthlin, had received $28,795.

Robb's media firm, The Communication Company of Washington, operated by Robert Squier, had been given $476,821 to place ads for the Democratic nominee, and pollster Peter Hart was paid $40,000.

While Republicans traditionally have raised more money, from fewer sources, the opposite appears to be true in the Coleman-Robb campaign. The average contribution to Robb was $353, compared with $81 to Coleman.

In the hotly contested lieutenant governor's race, Democrat Richard J. Davis' campaign reported that the former Portsmouth mayor went into the final weeks of the campaign with a debt of more than $70,000 on expenditures of $173,000. Davis reported raising $126,000, largely from Tidewater area developers, attorneys and auto dealers. Another $50,000 came from loans from prominent Tidewater businessmen.

The Republican candidate for lieutenant governor, State Sen. Nathan H. Miller of Harrisonburg, also showed contributions of $126,000, but he reported debts of only $3,750. Miller's largest contribution came from the Republican National Committee, which gave him $20,000.

In the race for attorney general, Republican Wyatt Durrette of Fairfax reported spending $317,000, more than twice the $137,000 reported by his Democratic opponent, Del. Gerald Baliles of Richmond.