Ezekiel Elliott ran for 147 yards and two touchdowns and caught a 72-yard touchdown pass, leading the Cowboys to a 40-10 victory on Sunday at Levi's Stadium.
Quarterback Dak Prescott completed 16 of 25 passes for 234 yards and three touchdowns for the Cowboys (3-3), who ended a two-game losing streak and moved to within two games of the first-place Philadelphia Eagles (5-1) in the NFC East. Prescott also ran for a touchdown.
"It's exactly what we wanted," Prescott said. "Those two close losses, lose them in two-minute fashion then having the bye week, time to adjust, and moving forward we did everything we needed to do."
Elliott, who had season highs for rushing yards and touchdowns while carrying the ball 26 times, didn't know whether he would be allowed to play until Tuesday. That was when a U.S. District judge in New York granted his motion for a temporary restraining order blocking his six-game suspension for violating the NFL's personal-conduct policy for alleged domestic assault against his ex-girlfriend.
"I put that aside when I get with these guys," Elliott said. "These guys do a good job of giving me something else to think about, keeping me up no matter what's going on out there. I'm just happy to be out here and be able to play with them and go and get another win."
"It's disappointing in all three phases as players and coaches," Shanahan said. "We have to play better. A lot better. I'm not going to question the effort, but we definitely didn't play well."
San Francisco rookie quarterback C.J. Beathard completed 22 of 38 passes for 235 yards and ran for a touchdown in his first NFL start. He was sacked five times and lost two fumbles.
"They brought a lot of pressure, which we hadn't seen them do much of," Beathard said. "I guess when you're a rookie they try to see what you know and put you on your heels a little bit."
The Cowboys capitalized on a fumble by 49ers punt returner Trent Taylor to take a quick 7-0 lead. Elliott bolted 14 yards on first down, gained 5 on second down, then scored on a 1-yard run with 12:42 left in the first quarter.
Dallas extended its lead to 14-0 on Elliott's 25-yard touchdown run midway through the opening quarter, capping a 74-yard drive.
"We saw in the Packers game before the bye that the offense started clicking in that fourth quarter and the running game started to open up, and we definitely carried over to this game," Elliott said. "The (offensive) line did a great job making creases for me to run the ball."
San Francisco cut the Cowboys' lead to 14-3 on Robbie Gould's 42-yard field goal late in the first quarter.
The Cowboys increased their lead to 20-3 on Prescott's 18-yard touchdown pass to tight end Jason Witten, who made a one-handed catch in the back right corner of the end zone with 10:26 left in the half.
Cowboys kicker Dan Bailey sustained a groin injury and was ruled out with 9:13 remaining in the first half. So, after Witten's touchdown, the Cowboys went for two points, but Prescott threw incomplete.
The 49ers had the ball at Dallas' 5 with 46 seconds left in the half, but Cowboys defensive end DeMarcus Lawrence ended that drive with a strip-sack of Beathard. Five different Cowboys had a sack.
"It's great," said Lawrence, who has 9.5 sacks, second most in the NFL. "All of us, a group of brothers, going after one common goal, and that's the quarterback. Just racing to get there. I'm just happy for everybody getting after the quarterback today."
Elliott struck again on Dallas' first play from scrimmage in the third quarter, grabbing Prescott's screen pass in the right flat and racing 72 yards for a score with 10:58 left. Safety Jeff Heath made the extra point, making it 27-3.
Prescott scored from 2 yards out on a quarterback draw with 43 seconds left in the third quarter, extending Dallas' lead to 33-3. Heath missed the PAT.
Dez Bryant made a leaping catch in the back of the end zone for a 2-yard score with 10:49 left to play. Heath connected, making it 40-3.
Beathard scored on a 4-yard run with 6:14 remaining.
"We are 0-7," Beathard said. "There's only one way to go -- and that's up."
NOTES: San Francisco rookie MLB Reuben Foster returned to action for the first time since sustaining an ankle injury in Week 1 against Carolina and started, but he sustained a rib injury in the third quarter. ... The 49ers honored former wide receiver Dwight Clark on "Dwight Clark Day" at Levi's Stadium. Clark is battling Lou Gehrig's disease, and the 49ers had a large group of his former teammates, including Joe Montana and Jerry Rice, on the field at halftime for a ceremony. ... Cowboys starting OLB Sean Lee returned to the lineup after missing two games with a hamstring injury. ... 49ers T Trent Brown left the game in the third quarter with a concussion and did not return.