Roughly 51 million viewers were drawn to just two networks Wednesday night, with the finales of Fox’s “American Idol” and ABC’s “Lost” putting up boffo numbers despite directly opposing each other.

The fourth-season ender of “Idol” easily led in all key categories from 8 to 10, but rookie drama “Lost” more than held its own. Fox’s victory on the night clinched its May sweeps crown in the key sales demo of adults 18-49 — the net’s second win in three years.

Although it was a weak month for a sputtering NBC (down 27% year-to-year in 18-49), four broadcasters — ABC, CBS, Fox and UPN — were up vs. a year ago while the WB was down slightly, according to Nielsen.

Overall, the six broadcast nets stopped the bleeding when it comes to losing viewers to cable, actually gaining audience. For the month in primetime, ABC, CBS, NBC, Fox, UPN and the WB combined for an 18.4 rating and a 51 share of the adults 18-49 audience, flat in share vs. May 2004 but up in rating (from 18.1).

ABC, with its rookie megahits, and UPN, with the addition of “America’s Next Top Model,” were up 28% and 25%, respectively, vs. last year.

On Wednesday, the final night of the May sweep and 2004-05 broadcast season, Fox and ABC accounted for 50% of the 18-49 viewing during the night’s first two hours.

“American Idol” (12.5 rating/31 share in 18-49, 30.27 million viewers overall) delivered the second-biggest finale numbers in its four seasons, up 4% from last year in 18-49 and 5% in total viewers. It led easily in each half-hour, posting the show’s best numbers since the auditions round in January.

For the season, “Idol” editions on Tuesday and Wednesday rank as the two top-rated programs in adults 18-49.

As for “Lost,” the ABC island thriller wrapped its boffo initial season with a strong 7.8 rating/19 share in 18-49 and averaged 20.71 million viewers overall — its best scores in most categories since January and its highest to date in men 25-54 (8.6/21) and teens (5.4/17). It ended its season as the highest-rated 8 o’clock drama among young adults in more than 10 years.

Most competitive demo for “Lost” vs. “Idol” was men 25-54, where the drama lagged the Fox smash by 4 shares.

Also on the night, NBC’s off-night series finale of “Law & Order: Criminal Intent” (5.0/12 in 18-49, 14.98m) bested ABC’s “Alias” finale (4.2/11, 10.08m), with the Alphabet skein winning in some male demos.

CBS didn’t do much with its original telepic “Amber Frey: Witness for the Prosecution” (2.1/5, 7.46m).

Overall for the month, ABC’s season finale of “Desperate Housewives” ranks as the No. 1 telecast in adults 18-49 (13.4/31), with the “Idol” finale placing second. In total viewers, the series finale of CBS laffer “Everybody Loves Raymond” finished on top (32.94 million), followed by the finales of “CSI” (30.73m) and “Housewives” (30.62m).

In addition to “Idol,” Fox’s 18-49 victory was highlighted by big numbers for rookie medical mystery “House,” which improved the Tuesday-at-9 hour vs. last year by 40% in 18-49 (7.3/18 vs. 5.2/13), and Thursday’s “The OC” (55% year-to-year gains on that night).

On the weekend, return of “Family Guy” bulked up the net’s Sunday, while the combo of “Cops” and “America’s Most Wanted” gave it a Saturday victory for the seventh straight sweep.

CBS, which won the month in adults 25-54 and total viewers, led in 18-49 for most of May, coming up short when “Idol” exploded over the final two nights.

Eye was paced by “CSI,” which teamed with “Survivor” and a rising “Without a Trace” to help the net win all four Thursdays in May, taking the night in 18-49, 25-54, 18-34 and total viewers.

Also, “Everybody Loves Raymond” and “Two and a Half Men” stood as the month’s top comedies, while Tuesday drama “NCIS” was up nicely year-to-year.

CBS took control of the 10 o’clock hour on weeknights leading into the late local news on its affils, rising 20% year-to-year in adults 25-54 (5.9/14 vs. 4.9/12).

A rising ABC rolled on Sundays with the trio of “Desperate Housewives,” “Grey’s Anatomy” and “Extreme Makeover: Home Edition,” and made big strides Wednesday with “Lost.” Net posted its highest May ratings across the board in four years.

There’s lots of room for improvement on other nights next season, though, as the net looks to fill in more pieces and challenge CBS and Fox for the demo crown.

NBC’s three top scores for the month came from episodes of “ER,” although the medical drama was down double-digits year-to-year. “The Apprentice” also was solid but down year-to-year, but there were significant dropoffs for two vets of the sked: “Fear Factor” and “Will & Grace.”

The netlet battle saw UPN and the WB tied in their target 18-34 demo with a 1.5 rating, with the former up 25% and the Frog off by 17%.

Although the WB was easily the higher-rated among scripted programs, UPN caught up on the back of “Top Model,” “WWE Smackdown” wrestling and the first two weeks of limited-run reality series “Britney & Kevin: Chaotic.” Biggest scripted success for UPN remains its Monday comedy block, led by “Girlfriends.”

At the WB, the Tuesday combo of “Gilmore Girls” and “One Tree Hill” rose year-to-year.