The Cape and Islands senate district - in place since the founding of the Massachusetts legislature - will remain largely intact thanks to the redistricting plan adopted by the state Senate yesterday afternoon.

"It's done and I'm pleased," said Cape and Islands Sen. Robert O'Leary following the vote late yesterday. Mr. O'Leary, a freshman senator and Democrat from Barnstable who was elected to the seat vacated last year by Sen. Henri Rauschenbach, fought to keep the two Islands in his district.

"The Islands were my first line of defense. There is a historic connection that would be a shame to lose," he said.

The laws require new lines be drawn for legislative districts every 10 years. The results of Census 2000, released earlier this year, showed population changes across the state. Because the population of the Cape and Islands has grown since 1990, the area's senate district needed to shed about 25,000 people.

"The big picture is demographics and it's about population moving in this direction," Mr. O'Leary said.

The redistricting map was unanimously approved by 36 state senators in a voice vote during a senate session yesterday.

Under the new plan, Mr. O'Leary will lose three precincts in Barnstable and two in Falmouth. These precincts will go to Sen. Therese Murray, whose district already includes Plymouth and most of Falmouth. Senator Murray's district will give up precincts in Wareham and Hanson in exchange for part of the Cape.

Last week the House of Representatives approved a redrawn map of house seats reflecting the population changes. Rep. Eric T. Turkington also kept the two Islands. The 10th U.S. congressional district will also be redrawn, but will still include the Cape and Islands. Cong. William Delahunt may lose parts of Brockton as part of the change.

A Barnstable native, Mr. O'Leary still represents 10 of the 13 precincts in the town in which he grew up, including the one where he lives.

"I am a hometown boy. And I still represent Barnstable," he said.

One state representative and a party leader staged a last-ditch move this week to amend the new district map to keep Barnstable intact. Rep. Demetrius Atsalis, a Barnstable Democrat, and Ray Gottwald, president of the Cape and Islands Democratic Council, tried to convince Mr. O'Leary to file an amendment that would give Senator Murray part of Mashpee instead of the three precincts in Barnstable.

But Mr. O'Leary refused to propose the amendment, saying that he had already taken his stand to keep the two Islands. "I took a position [to keep the two Islands] and in turn I established a position that I would have to compromise [by losing part of Barnstable]. This is a process; if you are drawing a line one place you have to be flexible in another," he said.

Mr. O'Leary said gaining Senator Murray as a representative of Barnstable is a positive step. "Frankly, there are advantages to this. She is already on the Cape, she and I work well together and this gets her more interested in Barnstable," he said. "I see it as a partnership, and another voice to speak for Barnstable."

Mr. O'Leary reiterated his own keen interest in both representing the two Islands and in keeping them together.

"I really thought about this a lot; there was some discussion about splitting the two Islands, and I thought that was a terrible idea," he said.

He noted that there was an outpouring of letters from town and county officials on both Islands urging the legislative redistricting committee not to break apart the existing senate district.

"The Islands have a distinct political character to them. They are high maintenance, but they are also very interesting. I find them great communities to work with. I don't want to lose them because they make my job more interesting," Mr. O'Leary said.

"The Islands are different but they also have similarities - whether it is housing or tourism or a perception in Boston and a reality at home," he added. "The Cape shares a lot of those similarities, but they are more extreme on the Islands. Then there are the institutional connections - the Steamship Authority, the hospital, job training, human services. Cape and Islands, Cape and Islands - you hear the phrase all the time. The historic connection will matter long after I leave this job."