Murray had scoring runs of 55 of 68 in the first quarter to stake Allen (15-1) to a 13-point lead. Ward's 1-yard run late in the third broke a 21-all tie.
Ward sealed Allen's second state title with a 67-yard touchdown run in the fourth quarter.
Lamar (15-1) was looking to become the first team from the Houston school district to win a state championship since 1985 when Yates beat Odessa Permian.
Quarterback Darrell Colbert threw for two touchdowns as Lamar was denied its first title since 1953.
Lamar scored before halftime to get within 21-15 and tied it in the third. Colbert rolled to his right and found Beau Wells, who stretched out in the end zone to grab an 18-yard TD pass. Alan Melgar missed his second extra point of the game, leaving the game tied at 21.
Colbert had 207 yards passing and rushed 19 times for 126 yards.
Oliver Pierce returned the ensuing kickoff 80 yards to the 16. Ward finished off the short drive with a 1-yard run, putting Allen back on top 28-21 with 26 seconds left in the third.
Lamar drove down to the Allen 33 before turning the ball over on downs with 6:17 remaining. Ward, who ran for 117 yards, burst through the middle on the next play on his 67-yard scoring run, giving Allen a two-touchdown lead.
Murray earned the starting quarterback job in Allen's sixth game. The Eagles averaged nearly 48 points in 11 games after the sophomore took over.
After Lamar scored on a safety when Allen snapped the ball out of the end zone on a punt, Murray evaded a tackler in the backfield and scampered 55 yards for a touchdown, giving Allen a 7-2 lead.
Murray did it again on Allen's next play from scrimmage. He ran untouched into the end zone on a 68-yard keeper with 19 seconds remaining in the first quarter.
Aided by a roughing the passer penalty that continued the drive, Lamar cut the deficit to 14-8. Colbert rolled to his left and found a wide open Cory Mitchell for a 41-yard touchdown pass.
Lamar was driving for the lead when Wells fumbled just before going down to the ground. Allen's Cameron Hartsfield scooped up the ball and returned it 57 yards to the 7.
Allen took advantage of the miscue when Murray hooked up with Cole Carter for a 12-yard TD pass with 2:24 left in the first half.
Lamar answered right before halftime when Colbert finished a five-play drive with a 7-yard run, making it 21-15.