TORONTO -- The Washington Wizards finally figured out how to defeat the Toronto Raptors this season.

It took them three overtime periods, but Washington came out on top 134-129 Thursday behind 31-point efforts from guard John Wall and center Marcin Gortat.

The Wizards (30-28) extended their winning streak to five games while avoiding being swept by the Raptors in the four-game season series.

Wall, who had nine assists and seven turnovers, made a driving layup late in the third overtime to give the Wizards a four-point lead, and they never looked back. Gortat added 12 rebounds before fouling out in the final minute of the third overtime.

"My feet and back are hurting, and I didn't even play," Wizards coach Randy Wittman said. "It's hard to put this game into words, there were so many changes in emotion, ups and downs."

"I like the way the guys battled," said Raptors coach Dwane Casey, whose team trailed by 12 points in the third quarter. "I thought we were flat in the first half again."

The Raptors (32-26) in saw their three-game winning streak end, and they suffered their ninth consecutive overtime loss at home dating to March 2009.

Forward Trevor Ariza added 16 points and 10 rebounds for the Wizards before fouling out in the third overtime. Forward Chris Singleton had 13 points, while guards Andre Miller and Bradley Beal each scored 11. Beal added 10 rebounds.

"We owed them, we need to come in here and set the tempo," said Washington forward/guard Martell Webster, who scored seven points in 37 minutes. "Now they have something to look forward to because this is a potential matchup in the playoffs. Now they have to go back to their tape and really focus on the way we played tonight."

Guard DeMar DeRozan led the Raptors with 34 points, and reserve guard Greivis Vasquez scored 14 of his 26 points in the fourth quarter. Vasquez added eight assists, but he committed six turnovers.

Toronto forward Amir Johnson contributed 16 points and nine rebounds before fouling out in the first overtime, and guard Kyle Lowry added 18 points and 10 assists before fouling out in the third overtime. Lowry played with an ankle injury during overtime. Raptors forward Patrick Patterson also fouled out in the first overtime.

Raptors guard/forward Terrence Ross scored 11 points before leaving the game in the second quarter with a sprained left ankle.

"We lost three key players," Casey said. "Losing Terrence Ross, you don't know what you have until you lose it. Gives us one more defender, shot-maker, that was a huge blow for us."

"They seemed to have control and then we seemed to have control," Wittman said. "We kept after it and we were lucky enough, we got three stops in a row down the stretch and converted at the other end, and that gave us a boost."

"I feel really bad right now. We've got to learn from mistakes," said Raptors center Jonas Valanciunas, who had seven points and 10 rebounds. "I feel I could have done much better job than I did. I'm going to watch the film and learn from it. We lost the game, that's the biggest thing."

DeRozan scored the Raptors' first four points of the third overtime to give Toronto a 122-120 lead, but he missed two free throws that would have extended the lead. Beal tied it before Vasquez hit a 3-pointer.

The Wizards came back to tie on a layup and a free throw by Gortat as Lowry fouled out.

Ariza and Webster followed with layups, and the Wizards led 131-127.

Forward Tyler Hansbrough missed two free throws on Gortat's sixth foul. The Raptors got to the line again when Ariza fouled out, and DeRozan made both shots. Wall restored Washington's four-point lead with 28.9 seconds left.

DeRozan gave Toronto a 116-114 lead to open the second overtime. Gortat tied it with a dunk. Gortat made two free throws with 43.1 seconds left to put Washington ahead 118-116. Each team missed a shot before DeRozan tied the game on a layup with 2.7 seconds left. The Wizards then put the ball in the basket but after time expired, sending the game to the third overtime.

"I definitely thought it was good," Ariza said. "Earlier in the season, we probably would have dropped our heads, but tonight shows that we're growing and getting better."

The game was tied at 106 after regulation. Gortat tied the game on a layup with 5.2 seconds to play, and Lowry missed a driving layup to send the game to overtime. Lowry fell heavily on the attempt.

"He stayed in the game, but he turned the ankle real bad," Casey said.

NOTES: Wizards F/C Nene (left knee MCL sprain) did not play after being injured Sunday. He is expected to be out for six weeks. ...Washington C Kevin Seraphin (sore right knee) did not take part in the shootaround on Thursday, and he was ruled out for the game. He is listed as day-to-day. ... F Drew Gooden was available to play in his first NBA game of the season after the Wizards signed him to a 10-day contract. He did not get into Thursday's game, however... The Raptors' victory at Cleveland on Tuesday made them 7-4 for February, assuring them of three consecutive months with a winning record for the first time since 2007. ... The Raptors continue their three-game homestand Sunday against the Golden State Warriors and end it March 7 against the Sacramento Kings. ... Washington plays the 76ers in Philadelphia on Saturday.