Ronald Reagan got an early scare from a surprisingly strong George Bush, but held off Bush's challenge to win a tight Texas primary tonight.

Bush's showing, however, aided by a big majority in his old congressional district in Houston, put a dent in Reagan's bandwagon strategy, which has been aimed at getting Bush out of the GOP contest as quickly as possible.

In the nonbinding Democratic popularity race, President Carter easily defeated Sen. Edward M. Kennedy, who was running neck-and-neck with "uncommitted."

The Democratic vote had no effect on the selection of convention delegates, who are chosen separately in a complex caucus system that began tonight. Preliminary returns from the precinct causcuses held around the state indicated that Carter might win 100 to 105 of the 152 delegates by the time the procedure is completed in June, Gary Mauro, executive director of the state Democratic party, said.

With 90 percent of the Republican precincts reporting, Reagan had 52 percent of the vote and Bush 47, with 2 percent uncommitted.

In the Democratic race, with 86 percent of the precincts reporting, Carter led with 56 percent, Kennedy had 22 percent and 19 percent were uncommitted. California Gov. Edmund G. (Jerry) Brown Jr., whose name was on the ballot despite his withdrawal from the race, had 3 percent.

Bush took an early lead in tonight's returns, and it appeared that his final-week blitz had paid extensive dividends, especially in the Houston area where Bush has lived for much of the last 32 years, and to a somewhat lesser extent around Dallas. Bush concentrated his personal campaigning in these areas during the five days before the primary.

But Reagan's expected strength in the rural areas held up as later returns came in and Bush's lead began to slip.

The 80 Republican delegates are awarded on the basis of results by congressional districts. Bush appeared likely to win seven of those districts and could pick up a total of 22 delegates to Reagan's 58.

In Indianapolis, where Reagan spent the night after a day of campaigning in North Carolina, his aides were surprised by Bush's strong showing but focused their comments on Reagan's victory in the battle for Texas delegates. f

"In all, this has been a very good day for Ronald Reagan, one which brings us that much closer to the Republican nomination in July," said Reagan press secretary Ed Gray.

In a late-night session with reporters, Reagan discounted the impact of the Bush showing, saying that his victory in the delegate contest had moved closer to the 998 delegates he needs for nomination. By the Reagan count, this figure is now about 675.

However, Reagan made it clear he'd like it very much if Bush were no longer in the race.

"It sure would ease my travel schedule," Reagan said.

James Baker, Bush's campaign manager, called the results "a very very significant showing."

"It should enable us hopefully to raise the money we have to raise to run the kind of campaign we want to run in California," Baker said. "We haven't made the decision finally on whether to run. It's contingent on being able to raise the money."

Baker said he believed that Bush's showing was aided by the emphasis the candidate put on foreign policy and said that the electorate is apparently dissatisfied with the possibility of a Carter-Reagan race and is looking "more and more" at bush as the alternative.

The Texas results left Reagan, for the second primary in a row, claiming victory after campaigns in which he was badly surprised by Bush. In contrast, Reagan was cautious in his statements after earlier primaries in which he soundly defeated his opponent.

A statement read to reporters by Gray late tonight stressed Bush's advantage in campaign spending. The Reagan statement said that Bush had outspent the former California governor by 10 to 1 in Texas.

Reagan has less than $1 million left of the $17.6 million that he is allowed to spend in the primaries under federal law. This means that he faces being outspent by Bush in the remaining primaries.

The Texas primary is the first of four contests over the next three days in which 251 GOP delegates are at stake. Reagan's forces hope to win about two-thirds of those and have been suggesting that the race is all but wrapped up.

Reagan won all 100 delegates at stake here in 1976 against President Ford, and had hoped for a big victory over Bush in Bush's own backyard.

Exit polls by NBC News showed that Bush had picked up voters who decided in the past week by a margin of 2 to 1, while Reagan got more than 60 percent of the voters whose minds were made up earlier. Bush was apparently aided by his heavy media campaign, something Reagan probably cannot afford in future primaries.

Bush's upset of Reagan in the popular vote in the Pennsylvania primary restored a little life to the GOP contest here this week, but not even Kennedy's victories in Pennsylvania and Michigan could turn the Democratic race into something real.

Bush was personally buoyed by his earlier popular vote win in Pennsylvania and had tried to duplicate that success here. He threw himself into the campaign here, spending the entire week in the state, sending his sons as surrogates to the tiny towns and barren rural areas of Texas while he stumped the Republican oasises around Houston and Dallas.

Where he could not get physically, he arrived on the air. A 30-minute "Ask George Bush" television show, which he used successfully in Pennsylvania, was taped in Houston Wednesday night and broadcast subsequently in 17 media markets across this "most barbarously large" state, as the late novelist Billy Brammer once called it.

Bush was the only major candidate to run a serious television advertising campaign. Altogether, he was expected to spend about $600,000 for the Texas race compared with an estimated $100,000 by Reagan.

In appearances around the cities, Bush tried to draw strength from the failed Iranian rescue mission by contrasting his experience as United Nations ambassador, envoy to Peking, and director of the Central Intelligence Agency with Reagan's relative lack of experience in foreign affairs.

He courted Texas patriotism by firlmly supporting the raid, but attacked Carter for what he called his contradictory foreign policy, his multiple secretaries of state, his gutting of the defense budget and his failure to maintain a strong military force. He also confronted charges that his past membership in the Trilateral Commission was a sign that he supported one-world government by urging Reagan to denounce the people who were distributing such campaign literature.

As a result of Bush's movement, Reagan altered his schedule here, canceling appearances in West Texas and adding several stops in the metropolitan areas. He was scheduled to make his last appearance in the state on Wednesday but campaigned here Thursday and returned Friday for a last stop in Houston.

Reagan's campaign was hampered by financial problems, and he was forced to run a low-budget operation that included almost no advertising.

The Democratic contest was even quieter, a fight mostly for the black and Chicano vote in this state. Kennedy began the week by flying to Mexico City to meet with Mexican President Jose Lopez Portillo and to attract the attention of Mexican-Americans here and in California. He then campaigned in south Texas, San Antonio and Houston, before leaving the state on Tuesday.

On Monday, Carter made what was billed as a nonpolitical trip to San Antonio to visit the burned survivors of the rescue mission, and his wife, Rosalynn, also campaigned in the state last week.