A reliable reliever for the first four years of his career, Ayala has dipped to 1-8 with a 5.77 ERA this season. He's appeared in 62 games, which ranks among the major league leaders.
Missing injured closer Billy Wagner, the NL East-leading Mets are having trouble nailing down games. Ayala should provide depth and another late-inning option for manager Jerry Manuel.
In return, New York is expected to send minor leaguer Anderson Hernandez to Washington once he clears waivers. A smooth-fielding middle infielder, Hernandez has a .138 career average in 87 big league at-bats.
"I'm surprised. It's a little bit late for a trade," Ayala said in Washington. "But for me, I passed my best times in this organization."
The 30-year-old Ayala was the longest-tenured Nationals player, having joined the club in 2003 when it was located in Montreal. He was 26-24 with a 2.82 ERA and nine saves in 258 appearances from 2003-07. He missed the 2006 season following elbow surgery, then returned to the mound last year and went 2-2 with a 3.19 ERA in 44 games.
"Sometimes guys just have off years. ... He's certainly healthy, and I think a change of scenery will help him," Nationals general manager Jim Bowden said. "I think going to a pennant race will help him.
"I can't say enough good things about Luis. He took the ball for us anytime he was asked and did a phenomenal job his entire career. He'll be missed."
New York general manager Omar Minaya is familiar with Ayala from his days as GM of the Montreal Expos.
"He had requested to be traded this year throughout the year," Bowden said. "We attempted to do so by the [non-waiver] trade deadline and just were not able to make a deal that made sense for us. With a month and a half left before free agency ... we felt we needed to get something for him."
The Mets claimed Ayala off waivers and the teams worked out a deal. New York entered Sunday with a two-game edge in the NL East over Philadelphia.
"They're fighting for first place, so I'm going to do my best to clear my mind and try to help the bullpen," Ayala said.
Ayala pitched two scoreless innings against the Mets on Wednesday during New York's 12-0 victory at last-place Washington.
"The two innings he faced us, he threw strikes," Manuel said Sunday. "He attacked the hitters. I kind of expect the same thing. Plus, he's experienced. That's important."
Ayala is expected to join the Mets for the finale of a four-game series in Pittsburgh on Monday. New York will make a move to create room for him on the 25-man roster.
To make room for Ayala on the 40-man roster, the Mets transferred outfielder Moises Alou from the 15-day disabled list to the 60-day DL. Alou is out for the season following hamstring surgery.
The Mets hope Ayala will help fortify a bullpen that was shaky even before Wagner went on the disabled list this month with a strained left forearm. The All-Star closer was expected to be activated from the DL on Monday, but discomfort in his pitching elbow Saturday changed those plans.
Wagner was examined by a team doctor Sunday in New York. He has stiffness in his elbow and will be re-evaluated Tuesday after a day of rest. It's uncertain when he might return.
The trade was made one day after the Mets' bullpen nearly wasted Pedro Martinez's longest outing of the season in a 7-4 victory over Pittsburgh.
New York took a 7-1 lead into the ninth inning, but the Pirates scored three times against rusty rookie Eddie Kunz. Pittsburgh brought the tying run to the plate against Pedro Feliciano, who retired the final two hitters to earn his second save.
The 25-year-old Hernandez hit .138 in 35 games with the Mets from 2005-07, and was batting .203 with five homers and 36 RBIs in 125 games this year at Triple-A New Orleans.
Hernandez batted .301 in 128 games at New Orleans last year and would provide depth at shortstop for Washington.
The Nationals' starting shortstop, All-Star Cristian Guzman, missed his third straight game with a sore left thumb Sunday. Backup infielder Alberto Gonzalez went on the DL on Aug. 14, retroactive to Aug. 5, due to a left hamstring strain.