The Cowboys will give up a first-round pick in 2009, plus a third- and sixth-rounder that year for Williams and a seventh-round pick in '10.
The Cowboys and Williams agreed to a five-year extension worth $45 million, including more than $20 million guaranteed, a source told ESPN senior NFL analyst Chris Mortensen. The contract language is still being finalized.
"I'm more happy to be a Dallas Cowboy than when I got my first bike," said Williams, an Odessa, Texas, native who went to the University of Texas.
Cowboys owner Jerry Jones believes Williams is a game-breaker who provides an immediate boost to a faltering offense that is now without quarterback Tony Romo, and views him as a potential long-term solution as the eventual replacement for an aging Terrell Owens, according to another high-ranking Cowboys source.
The Lions had been demanding a first-round draft choice just to consider a deal.
"We felt like right now that was the best thing for us to do as a football team. It gives us something for the future. You're looking at the possibility of having five of the first hundred  picks," Lions general manager Martin Mayhew said. "It was a pragmatic business decision."
Mortensen, attending the meeting of league owners in Tampa, reported that the Cowboys' NFC East rivals, the Philadelphia Eagles, had also made inquiries about Williams' availability.
In Dallas, Jones is known for a failed deal in which he traded two No. 1 draft picks to the Seattle Seahawks for wide receiver Joey Galloway in an attempt to provide Troy Aikman one more chance at the Super Bowl.
The Cowboys would like to find a way to avoid the two- to three-season span it seems to take to develop a young receiver for that role. But the Cowboys were concerned about how Owens would react to the addition of another prominent receiver and the possibility it would diminish his role rather than provide him occasional single coverage. The potential negative effect on the overall offensive chemistry is also a concern, and some in the organization preferred to wait until the offseason to make such a move.
However, Jones said that when he informed Owens of the trade, Owens was "ecstatic," mentioning that this should ease the double coverages he has been facing.
"You know Roy Williams is a great talent," Owens said during his Tuesday evening radio show, according to the Dallas Morning News. "You don't hear about him because he was in Detroit, but he has been productive."
Williams said the first phone call he received after the trade was from Owens, who has complained recently about not getting enough catches in an offense that lost Romo this week for perhaps a month with a broken pinkie on his throwing hand.
"To get a call from a guy like that, that's saying something," Williams said, according to the Morning News.
Williams said he and T.O. talked about winning.
"We got two guys out there that can really run, they're big, but as you know, both of them can really make spectacular catches," Jones said.
Williams will line up opposite Owens in an offense that has not had a clear No. 2 receiver since veteran Terry Glenn was waived this summer. Tight end Jason Witten leads the Cowboys with 39 catches after six games. Owens has 23 catches and five TDs.
After the trade, Williams talked as if he had found a new mentor in Owens, whom he made clear was "the No. 1 guy."
"I've never had an older wide receiver to show me the way," Williams said.
Jones said Tuesday he'd been trying to pry Williams from Detroit for two years.
Williams' best season was 2006, when he went to the Pro Bowl after catching 82 passes for 1,310 yards and seven touchdowns. He has 17 catches for 232 yards and a score this season and has 262 career passes for 3,884 yards and 29 TDs.
Williams is expected to begin practicing with the Cowboys on Wednesday and play in their game Sunday at St. Louis.
The 26-year-old Williams said it was tough to leave Detroit but said he was ready "to see what the playoffs feel like." Detroit was 21-48 since Williams arrived as a rookie and never made the postseason.
"Going from 0-5 to 4-2, you can't ask for anything better than that," Williams said.
Ed Werder and senior NFL analyst Chris Mortensen cover the NFL for ESPN. Information from The Associated Press was used in this report.