Gary Carter hit the first pitch Larry McWilliams threw him for a two-run homer in the 10th inning to give the New York Mets a 9-7 victory over the Pittsburgh Pirates today.

With the first-place Cardinals losing in Montreal, 7-5, the Mets trail by three games in the National League East going into the last week of the season. They will open a three-game series in St. Louis Tuesday night.

"We wanted to go to St. Louis no more than three games behind," Carter said. "Now we have to win three out of three there."

He had hit only .161 against Pittsburgh this season with no home runs and three RBI. "They've pitched me tough all year," he said. "It's sweet to get a home run against them . . . McWilliams likes to quick-pitch, so all I was thinking was first ball, fast ball."

"We've kept Carter under control all year," Manager Chuck Tanner of the Pirates said. "The long ball did us in today. That's how the Mets have been winning all year. That was the difference today, too."

The Mets blew leads of 4-0 and 6-3. The Pirates scored three runs in the eighth inning off reliever Roger McDowell to go ahead, 7-6.

Howard Johnson, who had singled in two runs in a four-run fourth, led off the Mets' ninth with a homer, his 11th of the year, to tie it at 7-7.

"Howard Johnson's home run shouldn't have been necessary," said Manager Davey Johnson of the Mets. "I had to go with the relievers who had done it for me in the past. But Roger didn't have it today, and when Jesse (Orosco) came in, I was afraid he didn't have it either."

Orosco (7-6) didn't, struggling in his 2 2/3 innings, but he got the victory.

For the up-for-sale Pirates, it might have been the last game in Pittsburgh. The game drew 13,956 fans for a season total of 735,900, their lowest total since 1968. The defeat was their 100th. They hadn't lost that many since losing 101 in 1954.