Ovechkin ripped a shot from the right circle over a blocker at 10:27 of the second period to make it 3-1 and tie Messier. He later added an empty-net goal with seconds remaining to pass the Hall of Famer.
Ovechkin, who received a hearty ovation from the Ottawa crowd, is 13 goals behind Mike Gartner for seventh on the career goals list. His 695 goals have come in 1,135 career games.
He has 37 goals this season.
The Associated Press contributed to this report.